So, I tried to create 2 floating divs inside a parent div whose position
is set to fixed
and the 2 children floats to left
and right
. But for some reson the code is not working as expected. Here is my fiddle: http://jsfiddle.net/adityasingh773/cqn73m0p/
What I tried to achieve is make these 2 children divs float according to their CSS property i.e. to the left and right. I don't like to assign width to each child elements as it will make the code non-responsive.
Here is what I tried
HTML
<div class="container">
<nav class="top-nav">
<section>
<div class="left">left</div>
<div class="right">right</div>
</section>
</nav>
</div>
And CSS
body{
margin: 0;
padding: 0;
}
.container{
width: 80%;
margin: 0 auto;
}
nav.top-nav{
position: fixed;
top: 0;
display: block;
}
.left{
position: relative;
float: left;
}
.right{
position: relative;
float: right;
}