我创建了以下布局:
<div class="title" id="m1">
<div class="chkbx">something</div>
<div class="name">
<a href="#" onclick="doSomething('1');">Dummy #1</a>
</div>
</div>
// .. the div above repeats several times
我正在使用以下 CSS:
div.title { border: 1px black solid; }
div.chkbx {
clear:both;
float:left;
padding:2px;
text-align:right;
width:5%;
}
div.name {
float:left;
width: 50%;
}
并且希望所有 class=title
周围都有边框,但在顶部只能看到一些奇怪的线条。请让我知道我做错了什么。
非常非常感谢!
最佳答案
您可能正在 float 内容。在容器上设置 overflow: hidden
。
- > http://complexspiral.com/publications/containing-floats/解释为什么你会出现这种行为
- > http://www.ejeliot.com/blog/59列出了各种避免它的方法,其中大部分都比上面描述的要好,包括溢出方法。
关于html - 分区中的分区 : layout question,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2765755/