我正嘗試在這裏用側邊欄和右側的內容部分創建一個非常常見的佈局。我的邊欄部分的寬度爲fixed
(這裏爲120px),我希望右側的容器佔據頁面的剩餘空間(右邊距60px)。讓div在邊欄後留下剩餘空間
這裏的標記的樣子:
<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>
這裏是上面的小提琴,以及:http://jsfiddle.net/6nLtp/
在我的情況下,發生了什麼是正確的容器會側邊欄下方,並採取100%的寬度。不過,我預計它會在側邊欄右側留下剩餘空間(頁面右側的邊距爲60px)。當我指定寬度時,容器與邊欄一起出現,但我不確定爲什麼需要這樣做?由於div元素(邊欄和右邊的容器都是浮動的),爲什麼正確的內容不能與邊欄一起粘貼?
結帳http://stackoverflow.com/questions/580195/css-layout-2-column-fixed-fluid,具體的jsfiddle它鏈接到:HTTP: //jsfiddle.net/uEj55/1/ – stefancarlton
[CSS div divs each other]可能的重複](http://stackoverflow.com/questions/446060/css-two-divs-next-to-each-other) – jstricker