2
I’m not being able to align two elements side by side correctly.
The container of these two div
'It’s like I’m with height: 0;
or initial
, only recognizing the height of the element without the float: left;
, which in this case are the navigation links.
But I wanted the container also respond to the element’s height <div id="logo">
, for he now seems to be behaving as an element with position:absolute;
that regardless of their height, the height
of container does not expand as it should happen if this element had no float
or position:absolute;
.
The first image is as it currently is. The second image is as it should be.
<header>
<div id="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;
}
I don’t understand what the problem is. Can you explain what you wanted the result to be?
– Sergio
Actually I did not realize that the problem did not appear here on the site, but the browser clearly shows. div does not consider the "Logo" height of the list only (menu)
– Steve Alisson
Good afternoon Steve, it’s not that the question here doesn’t work, it’s because you didn’t put all the css, it could be anything that is causing the problem, it won’t help just by an image showing the problem, you have to create an example of such problem that can be reproduced, I recommend you follow these tips carefully: http://answall.com/help/mcve. - take this as a constructive criticism :)
– Guilherme Nascimento