san*_*e11 7 html css xhtml height
我在这里做了很多阅读,但找不到我答案的解决方案.
我有一个容器div,有多个浮动的左div,按照下面的html.
<div class="catbg0" id="b1">
<div class="catb1">#</div>
<div class="catb2">Board Name</div>
<div class="catb3">Topics</div>
<div class="catb4">Posts</div>
<div class="catb5">Last Post</div>
<div class="clearboth"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是.catbg0没有特定的高度,.catb2的内容将它推到它的高度,因为内容可以变化,我不能设置一个特定的高度.我希望其余的.catb类转到.catbg0类的100%高度,但设置高度:100%; 不起作用.
以下是与上述相关的CSS.
.catb1 {float: left; width: 9%; height: 100%; min-height: 100%;}
.catb2 {float: left; width: 52%; height: 100%; min-height: 100%;}
.catb3 {float: left; width: 8%; height: 100%; min-height: 100%;}
.catb4 {float: left; width: 8%; height: 100%; min-height: 100%;}
.catb5 {float: left; width: 23%; height: 100%; min-height: 100%;}
.clearboth {clear: both; height:0; width: 0; margin: 0; padding: 0;}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢.
据我所知,只有具有位置的块:绝对可能是 100% 高度及其子项。
如果您确定 .catb2 具有 .catb* 的最大高度,请尝试添加包装器:
<div class="catbg0" id="b1">
<div class="catb2">Board Name</div>
<div class="wrapper">
<div class="catb1">#</div>
<!-- margin == catb2 width -->
<div class="catb3">Topics</div>
<div class="catb4">Posts</div>
<div class="catb5">Last Post</div>
</div>
<div class="clearboth"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.catbg0 { position: relative; }
.wrapper { position: absolute; width: 100%; height: 100%; }
.catb2 { margin-left: /* catb1 width here */ }
Run Code Online (Sandbox Code Playgroud)
PS 也许它对你有用 - A new microclearfix hack
| 归档时间: |
|
| 查看次数: |
9150 次 |
| 最近记录: |