I have four elements of a menu, the first one on the left and the other three on the right, but when floating ul li
float:right;
the elements are positioned out of order.
[Menu3] [Menu2] [Menu1]
But the elements should be displayed in this order:
[Menu1] [Menu2] [Menu3]
The full running code: https://jsfiddle.net/u1eu2dku/
How do I display the items in order, but in the same menu layout?
.menu {
width: 100%;
float: left;
}
.menu ul li {
float: right;
list-style-type: none;
text-align: left;
}
.menu ul li a {
padding: 10px;
}
<div class="menu">
<ul>
<li style="float:left;">logo</li>
<li><a href="">Menu1</a></li>
<li><a href="">Menu2</a></li>
<li><a href="">Menu3</a></li>
</ul>
</div>
One option is to do it with flexbox, justifying the elements at the end of the row and allowing the first of these to "grow" so that it occupies the rest of the space on the left:
Shaz's solution seems perfect to me but if for some reason you need compatibility with browsers that don't support flexbox you can also use
display:inline-block
and align to the right withtext-align
: