I'm not able to align two elements side-by-side properly.
The container of these twodiv
's looks like it has height: 0;
or initial
, only recognizing the height of the element without float: left;
, which in this case are the links of navigation.
But I wanted the container to also respond to the height of the <div id="logo">
element, since it now seems to be behaving like an element with position:absolute;
, regardless of its height,% container does not expand as it should if this element does not have any height
or float
.
Thefirstimageishowitiscurrently.Thesecondishowitshouldbe.
<header><divid="top-bar">
<div id="logo"></div>
<nav id="menu">
<ul>
<li><a href="#">Sobre</a></li>
<li><a href="#">Trabalhos</a></li>
<li><a href="#">Contato</a></li>
</ul>
</nav>
</div>
</header>
CSS
a {
text-decoration: none;
color: #4B4B4B;
}
div#top-bar {
background-color: #f14949;
padding: 25px 80px 25px 80px;
}
div#logo {
vertical-align: middle;
float: left;
width: 86px;
height: 51px;
background-color: #4B4B4B;
border-radius: 6px;
}
nav#menu {
text-align: right;
}
nav#menu ul {
list-style: none;
}
nav#menu li {
display: inline-block;
}