【发布时间】:2013-03-14 08:28:30
【问题描述】:
我的问题很像这样:
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;
}
红色区域需要是可访问的父 div,黄色区域需要在底部占据其余的宽度以调整窗口大小。
谢谢大家的考虑。
【问题讨论】:
-
您想在哪里获取内容?仅在
.left和.right内?还是在容器内.boxdiv? -
你能画出你需要的东西吗?
-
有什么理由不希望将
.left设置为position: absolute吗?
标签: css