I am currently designing a header that includes a brand logo and a navigation menu. The header is nested within a div called container, and the HTML markup looks like this -
<div class="container">
<div class="head">
<div class="brand>Brand Name</div>
<div class="nav'>Navigation Content Here</div>
</div>
</div>
The CSS styles I have implemented are as follows:
.container{
width:100%;
margin:10% auto;
}
.head{
float:left;
width:100%
}
.brand{
float:left;
margin:0 3%;
width:auto;
}
.nav{
float:right;
margin:0 3%;
width:auto
}
My issue is that all the content overflows outside of the main container <div>
causing it to have a height of 0px. Although the content appears how I want it to, the main container has no height.
I want the brand logo and navigation menu to be displayed side by side. It would be greatly appreciated if you could create a fiddle with the code provided. Thank you in advance.
EDIT: Apologies for not researching before posting my query. The Clearfix hack has proven to be a helpful solution, but there are alternative methods as well. You can find more information on this topic here - How do you keep parents of floated elements from collapsing?