Reputation: 338
I'm having trouble aligning my navigation to the right of the header. Searching on the web, I think the problem is because I'm aligned the items vertically to the center, and the float option isn't working with that.
Any clues?
See: http://jsfiddle.net/PabloArteeL/T7JDJ/
HTML:
<header>
<div class="logowrapper" style="padding-left:1em;">
<div class="logo"></div>
</div>
<nav><a href="#">SOME LINK</a>
</nav>
</header>
CSS:
header {
background-color: #eaeaea;
height: 80px;
margin: 10px;
}
.logowrapper {
display: table-cell;
height: 80px;
vertical-align: middle;
text-align: center;
}
.logo {
display: inline-block;
background-image: url("http://placehold.it/250x40");
width: 250px;
height: 40px;
}
nav {
right: 0px;
display: table-cell;
vertical-align: middle;
}
nav a {
color: black;
text-decoration: none;
}
Desired effect:
Upvotes: 0
Views: 2438
Reputation: 323
Imagine's answer will only work if it is text. A better solution uses floats and margin. For general elements side by side it's best to use display: block
over display: table-cell
which emulates a <td>
Just change the margins, and widths to your liking.
Upvotes: 0
Reputation:
try this :
<header>
<div class="logowrapper">
<div class="logo"></div>
</div>
<div class = "link">
<nav><a href="#">SOME LINK</a>
</nav>
<div>
</header>
css :
header {
background-color: #eaeaea;
height: 80px;
margin: 10px;
}
.logowrapper {
height: 80px;
vertical-align: middle;
text-align: center;
padding-left:1em;
float: left;
padding: 18px;
}
.logo {
background-image: url("http://placehold.it/250x40");
width: 250px;
height: 40px;
}
.link {
padding: 30px;
}
nav {
right: 0px;
vertical-align: middle;
text-align: left;
float: right;
}
nav a {
color: black;
text-decoration: none;
}
Upvotes: 0