I am trying to create a very common layout here with a sidebar and the content section on the right. The width of my sidebar section is fixed
(here 120px) and I want the container on the right side to take up the remaining space of the page (with a margin of 60px the right end).
Here's how the markup looks like:
<body>
<div class="wrapper">
<div class="content">
<div class="left-sidebar">
<ul class="sidebar-menu">
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
<div class="right-main-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
</div>
</body>
Here's the fiddle of the above as well: http://jsfiddle.net/6nLtp/
In my case, what's happening is that the right container is going below the sidebar and taking 100% width. However, I expected it to take just the remaining space towards the right of the sidebar (and with a margin of 60px on the right of the page). The container comes along with the sidebar when I specify the width, but I am not sure why do I need to do that? Since the div elements (sidebar and the right container are floated), why can't the right content just stick along with the sidebar?