我的问题是很多像这样的: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