Reputation: 469
This is killing me for hours already :'( Can anyone help me to position the logo and navbar inside the header???
I am trying to put the "logo" inside the header (to the left side) and "navbar" inside the header (to the right side) but even though i tried many different properties my navbar is always outside of the header container... Header should be fixed.
<header>
<a href="#" id="logo">Logo</a>
<ul id="nav" class="nav">
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</header>
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'>
html, body{
margin:0px; padding:0px; height: 100%; }
section {
height: 100%;
}
header{
z-index: 1;
position:fixed;
width:100%;
background:rgba(0,0,0,0.1);
}
header ul{
float:right;
}
header ul li{
display: inline;
float:left;
}
header a{
color:white;
background:rgba(0,0,0,0.1);
display:inline-block;
padding:0px 30px;
height:60px;
line-height:60px;
text-align:center;
font-family: 'Roboto Slab', serif;
text-decoration:none;
text-transform:uppercase;
letter-spacing:2px;
font-weight:700;
}
Upvotes: 1
Views: 13095
Reputation: 691
Your ul
had margin and padding :)
header ul{
float:right;
padding: 0;
margin: 0;
}
header ul li{
display: inline;
float:left;
}
header a{
color:white;
background:rgba(0,0,0,0.1);
display:inline-block;
padding:0px 25px;
height:60px;
line-height:60px;
text-align:center;
font-family: 'Roboto Slab', serif;
text-decoration:none;
text-transform:uppercase;
letter-spacing:2px;
font-weight:700;
}
I also changed the left and right padding on the header a
for the sake of the fiddle.
Upvotes: 4
Reputation: 9593
Updated Fiddle Here is the modified css for your code:
#logo {
float: left;
position: aboslute;
}
#nav {
white-space: nowrap;
margin-top: 0;
margin-right: 0;
}
header {
z-index: 1;
position:fixed;
width:100%;
background:rgba(0, 0, 0, 0.1);
height: 60px;
}
Upvotes: 2
Reputation: 3500
Here:
header ul
{
float:right;
margin: 0;
}
header ul li
{
display: inline;
float:left;
margin: 0;
}
Also cleaned up your code a little:
Upvotes: 1