Reputation: 734
I need the following output with the given html, i used display:table
property with ul ul
and display:table-cell
property with their li
childeren, every ul ul
has four child expect last ul ul
, i already set the width of every li
child of ul ul
, but its not working with last raw, I dont want to edit my html, please help me, why its happening. Thanks in advance
Expect output : -
Result I am getting:-
Html:-
<div>
<ul>
<li>
<ul>
<li><a href="#">11</a></li>
<li><a href="#">12</a></li>
<li><a href="#">13</a></li>
<li><a href="#">14</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">21</a></li>
<li><a href="#">22</a></li>
<li><a href="#">23</a></li>
<li><a href="#">24</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">31</a></li>
<li><a href="#">32</a></li>
<li><a href="#">33</a></li>
</ul>
</li>
</ul>
CSS:-
ul {
list-style: none;
margin: 0;
padding: 0;
width: 100% !important;
}
div > ul{
display: block;
width: 100%;
}
div > ul > li {
width: auto;
}
div > ul ul{
display: table;
table-layout: fixed;
}
div > ul ul li {
border-left: 1px solid #ebebeb;
display: table-cell;
line-height: 0.9;
padding: 5px 20px;
width: 25%;
}
Upvotes: 3
Views: 155
Reputation: 2480
Without adding any li
, Try this Demo
ul {
list-style: none;
margin: 0;
padding: 0;
width: 100% !important;
}
div > ul{
display: block;
width: 100%;
}
div > ul > li {
width: auto;
}
div > ul ul li {
border-left: 1px solid #ebebeb;
display: table-cell;
line-height: 0.9;
padding: 5px 20px;
}
Upvotes: 1
Reputation: 1834
you just have to main the length of li
<ul><li></li>
<li></li>
<li></li>
<li></li>
Upvotes: 1
Reputation:
<div>
<ul>
<li>
<ul>
<li><a href="#">11</a></li>
<li><a href="#">12</a></li>
<li><a href="#">13</a></li>
<li><a href="#">14</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">21</a></li>
<li><a href="#">22</a></li>
<li><a href="#">23</a></li>
<li><a href="#">24</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">31</a></li>
<li><a href="#">32</a></li>
<li><a href="#">33</a></li>
<li><a href="#"> </a></li>
</ul>
</li>
</ul>
because u missed the cell in thrid row
Upvotes: 3
Reputation: 1178
Just add another empty <li></li>
to your last row and it will be fixed, like this:
<ul>
<li><a href="#">31</a></li>
<li><a href="#">32</a></li>
<li><a href="#">33</a></li>
<li></li>
</ul>
Upvotes: 2