I'm trying to create navigation menu and I've added float: right;
to my li
tag in css, I also have div named .header
which happens to be the background of the menu.
From some reason, when I add float the background just dissapears and when I removed the float the background has returned to his place.
body{
margin: 0;
}
.header{
width: 100%;
height: 10%;
background: #616161;
}
ul#nav{
list-style: none;
}
ul#nav li{
display: inline-block;
padding-right: 25px;
float: right;
}
HTML
<div class="header">
<ul id="nav">
<li><a href="#">Website</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
</ul>
</div>
My code is pure, no css, no margin, only display that might be causing this problem of background positioning.
Is there a possibility to keep the text in right float and background together?
Before and after float using: