I'm in the process of developing my first website and I'm having an issue with the Navigation Bar. I'm using CSS rules to align the bar but unfortunately when I set the rules to float:right;
my text is floating right but it’s lining up backwards on the bar. How can I float the text over to the right and align the text correctly?
.nav ul li {
display: inline-block;
float: right;
padding: 10px 10px;
}
.nav {
background-color: black;
position: fixed;
width: 100%;
top: 0px;
margin: auto;
font-weight: bold;
border-bottom: 2px solid orange;
margin-top: 5px;
}
.nav ul li a {
color: orange;
text-transform: uppercase;
letter-spacing: 0.05em;
padding: 0px 10px;
}
<div class="nav">
<ul>
<li><a href="#">Home</a>
</li>
<li><a href="#">About</a>
</li>
<li><a href="#">Contact</a>
</li>
<li><a href="#">Portfolio</a>
</li>
<li><a href="#">FAQ</a>
</li>
</ul>
</div>
You need to float the
ul
list, not individual list itemsli
.Setting
float: right
onli
allows the first list item to align to the right first and then the rest of the items take their positions similarly. It caused the direction of the list from right to left.