Reputation: 9787
I have an ul that works fine, but when I add a nested ul the li above, moves. Does anyone know why? how to solve it?
I have the example here: http://jsfiddle.net/y5DtE/
HTML:
<ul>
<li> first
<ul>
<li> 1.2 </li>
</ul>
</li>
<li> second </li>
<li> third eally, really long </li>
</ul>
CSS:
body {
margin:0px;
}
ul {
margin:40px auto;
list-style-type:none;
padding:0;
text-align: center;
}
ul li {
padding: 0 15px;
margin-right: 5px;
background-color: #f2f2f2;
display: inline-block;
height: 30px;
line-height: 30px;
font-family: verdana;
font-size:10px;
color: #666
}
ul li:last-child { margin-right: 0px; }
ul li ul {
margin:5px 0;
}
Upvotes: 0
Views: 278
Reputation: 606
To make sublist go under parent element apply this:
ul li {
display: block;
float: left;
}
To prevent floating of sub items add the following rule:
ul li ul li{
float: none;
}
Upvotes: 1