I have two divs inside a div, I want them both adjacent to each other with a margin of 10px or so separating them but instead they appear one above the other.
<div>
<div class="post" id="fact">
</div>
<div class="post" id="sortbar">
</div>
</div>
Here is my styling:
#fact{width:200px; margin-left:auto; margin-right:auto;} #sortbar{margin-left:auto; margin-right:auto;}
The whole code is within a div container wrapper with these properties:
#wrapper {
float:left;
margin-top:10px;
width:728px;
}
You have two options (choose one or the other but not both).
float: left;on both#factand#sortbardisplay: inline-block;on both#factand#sortbarThe second option is better because you don’t have to fix the clearing and such, as well as the fact that inline-block works a lot better layout-wise than left floating.