我的問題是很多像這樣的:CSS - 兩個div固定和填充但絕對位置
Two divs, one fixed width, the other, the rest
但也有一些注意事項,使答案有點不同。
沒有使用javascript,有沒有辦法讓兩個包含的div,一個浮動在一個鎖定寬度的權利,另一個堅持容器的底部設置的高度,並採取剩餘的可用寬度?這裏最困難的部分是上面的所有內容,並且圍繞這兩個div必須保持可點擊並與父div關聯。
這裏是小提琴:http://jsfiddle.net/W7Ljd/
下面是代碼:
.box {
position: relative;
width: 200px;
height: 200px;
padding: 5px;
background:lightcoral;
}
.left {
position: absolute; /* ------ Get Rid of these lines */
bottom: 5px; /* ------ */
width: 80px; /* ------ */
overflow:hidden;
height: 20px;
background: lightyellow; /* Take up rest of space */
}
.right {
float: right;
width: 100px;
height: 100%;
background: lightblue;
}
紅色區域需要爲可訪問父格,黃需要在底部佔用的其餘窗口的寬度應該調整大小。
感謝您的考慮,夥計們。
你想要什麼內容?只在'.left'和'.right'內?或者也在容器'.box'的div? – frozenkoi 2013-03-14 00:10:19
你能畫出你需要的圖片嗎? – 2013-03-14 00:10:33
是否有理由不將'.left'設置爲'position:absolute'? – John 2013-03-14 00:15:46