Reputation: 2362
I have a UL > li's
in my html, and the li's are set to float: left
.
My doubt is how to separate them, inside a father div, equally, so that doesn't matter how many li's are in the ul, they still have the same spacing between them?
If li's are not 'good' to do that, what is better?
Upvotes: 2
Views: 6482
Reputation: 92803
As per I understand is better you can write like this:
li + li{
margin-left:10px;
}
You can also use display:table
property for this. Write like this:
ul{
display:table;
width:100%
}
li{
display:table-cell;
}
Upvotes: 5
Reputation: 21386
You may set a border to the ul
and set a margin to child li
s. Or you may set border both to ul
and li
s. The reason for parent border is, when li
s merge, they will combine their borders creating a double border where they meet.
Here is a Live Demo showing both methods.
Upvotes: 0