With the following HTML you can do this (and, frankly, with other HTML you could do this...) but you should use tables.
Anyway, that said, the HTML I'm working with:
<ul>
<li class="head">
<span class="col1">Food</span>
<span class="col2">Calories</span>
</li>
<li>Fruits
<ul>
<li>
<span class="col1">Apple</span>
<span class="col2">90</span>
</li>
<li>
<span class="col1">Grape</span>
<span class="col2">5</span>
</li>
<li>
<span class="col1">strawberry</span>
<span class="col2">16</span>
</li>
</ul></li>
<li>Vegetable
<ul>
<li>
<span class="col1">Cucumber</span>
<span class="col2">12</span>
</li>
<li>
<span class="col1">Onion</span>
<span class="col2">29</span>
</li>
</ul></li>
</ul>
And the CSS:
li.head {
font-weight: bold;
}
span.col1,
span.col2 {
display: inline-block;
width: 48%;
}
ul > li > ul > li {
padding-left: 10%;
height: 0;
line-height: 0;
overflow: hidden;
-webkit-transition: all 1s linear;
}
ul > li:hover > ul > li {
height: 2em;
line-height: 2em;
-webkit-transition: all 1s linear;
}
ul > li > ul > li span:first-child::before {
content: '-';
width: 40%;
}
li li:nth-child(odd) span {
background-color: #aaf;
}
JS Fiddle demo.
To allow for keyboard navigation, and showing the nested foods/calorie values in response to tab-events, I've amended the HTML a little to wrap the fruits and vegetable text with an a element:
<ul>
<li class="head">
<span class="col1">Food</span>
<span class="col2">Calories</span>
</li>
<li><a href="#">Fruits</a>
<ul>
<li>
<span class="col1">Apple</span>
<span class="col2">90</span>
</li>
<li>
<span class="col1">Grape</span>
<span class="col2">5</span>
</li>
<li>
<span class="col1">strawberry</span>
<span class="col2">16</span>
</li>
</ul></li>
<li><a href="#">Vegetable</a>
<ul>
<li>
<span class="col1">Cucumber</span>
<span class="col2">12</span>
</li>
<li>
<span class="col1">Onion</span>
<span class="col2">29</span>
</li>
</ul></li>
</ul>
With the following CSS:
li.head {
font-weight: bold;
}
li a {
color: inherit;
text-decoration: none;
}
span.col1,
span.col2 {
display: inline-block;
width: 48%;
}
ul > li > ul > li {
padding-left: 10%;
height: 0;
line-height: 0;
overflow: hidden;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}
ul > li a:focus + ul > li,
ul > li:hover > ul > li {
height: 2em;
line-height: 2em;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}
ul > li > ul > li span:first-child::before {
content: '-';
width: 40%;
}
li li:nth-child(odd) span {
background-color: #aaf;
}
JS Fiddle demo.
Both of these, however, assume that you want to hide automatically, and show based on user-interaction. If that assumption's incorrect then the transitions aren't necessary.
Incidentally, an accordion-like table solution:
<table>
<colgroup>
<col class="foods" />
<col class="calories" />
</colgroup>
<thead>
<tr>
<th>Food</th>
<th>Calories</th>
</tr>
</thead>
<tbody>
<tr class="header">
<td colspan="2">Fruits</td>
</tr>
<tr>
<td>Apple</td>
<td>90</td>
</tr>
<tr>
<td>Grape</td>
<td>5</td>
</tr>
<tr>
<td>Strawberry</td>
<td>16</td>
</tr>
</tbody>
<tbody>
<tr class="header">
<td colspan="2">Vegetable</td>
</tr>
<tr>
<td>Cucumber</td>
<td>12</td>
</tr>
<tr>
<td>Onion</td>
<td>29</td>
</tr>
</tbody>
</table>
CSS:
.foods,
.calories {
width: 8em;
}
tbody tr.header {
height: 2em;
line-height: 2em;
}
tbody tr,
tbody tr td {
max-height: 0;
line-height: 0;
overflow: hidden;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}
tbody tr td:first-child {
padding-left: 2em;
}
tbody tr.header td {
padding: 0;
}
tbody:hover tr {
height: 2em;
max-height: 2em;
line-height: 2em;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}
JS Fiddle demo.
This makes the same assumptions as previously, that you want to control the visibility by hovering over the header to show the hidden content.
And, just for kicks, adding keyboard-navigation (with tab), using the tabindex attribute on the tr.header elements:
<table>
<colgroup>
<col class="foods" />
<col class="calories" />
</colgroup>
<thead>
<tr>
<th>Food</th>
<th>Calories</th>
</tr>
</thead>
<tbody>
<tr class="header" tabindex="1">
<td colspan="2">Fruits</td>
</tr>
<!-- unchanged from the previously-posted table mark-up -->
</tbody>
<tbody>
<tr class="header" tabindex="2">
<td colspan="2">Vegetable</td>
</tr>
<!-- unchanged from the previously-posted table mark-up -->
</tbody>
</table>
And CSS:
/* Other CSS remains the same */
tr.header:focus ~ tr,
tbody:hover tr {
height: 2em;
max-height: 2em;
line-height: 2em;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}
tr.header:focus {
outline: none;
font-style: italic;
background-color: #ffa;
}
JS Fiddle demo.