mardi 22 avril 2014

Horizontal list items - fit to 100% with even spacing


Vote count:

0




I have a simple list and i am trying to get the list items to be evenly spaced horizontally, but still fill 100% of the width of the container regardless of the width of the container.


I do not want each list item to be of equal width, but instead the spacing between each list item to be even:


jsfiddle: http://ift.tt/1jFbjWa


Here is my markup and css:



<ul>
<li>This is menu item 1</li>
<li>Number 2</li>
<li>Item Number 3</li>
<li>Menu 4</li>
</ul>


and the following css:



ul {
width: 100%;
background: #cacaca;
margin: 0;
padding: 0;
}
li {
list-style-type: none;
display: inline-block;
padding-right: 10%;
width: auto;
margin-right: 0.5%;
background: #fafafa;
padding-left: 0;
margin-left: 0;
}
li:last-child {
margin-right: 0;
padding-right: 0;
}


asked 28 secs ago






Aucun commentaire:

Enregistrer un commentaire