[英]CSS block bottom border
I have a div that I would like to have a bottom border. 我有一个div,我希望有一个底部边框。
This can be see at http://jsfiddle.net/R5YN2/ 这可以在http://jsfiddle.net/R5YN2/看到
What causes the border to not be placed right at the bottom? 是什么原因导致边框不能放在底部?
Your container element isn't accounting for the float
ed elements and is basically collapsing. 您的容器元素不考虑
float
ed元素,并且基本上是折叠。
Give it the property overflow: auto
and it should work: 给它提供属性
overflow: auto
,它应该可以工作:
#recurring-header-wrapper {
display: block;
padding-bottom: 10px;
border-bottom: 1px solid #ccc;
overflow: auto;
}
Demo: http://jsfiddle.net/R5YN2/14/ 演示: http : //jsfiddle.net/R5YN2/14/
Also, go easy on the class names. 另外,在类名上轻松一些。 You can have selectors that target classes inside of elements:
您可以具有针对元素内部的类的选择器:
#recurring-header-wrapper .label
Which matches only .label
elements inside of the recurring-header-wrapper
element. 它仅与
recurring-header-wrapper
元素内的.label
元素匹配。 No need for huge class names. 无需庞大的类名。
If you float things you have to clear as well. 如果你漂浮的东西,你也必须清除。
Read this: http://www.positioniseverything.net/easyclearing.html 阅读此: http : //www.positioniseverything.net/easyclearing.html
This is what you're looking for. 这就是你要找的东西。 Add the class .clearfix to your wrapper-div (#recurring-header-wrapper).
将类.clearfix添加到wrapper-div(#recurring-header-wrapper)。
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
It is displayed at the bottom (it ends there, the text is overflowing. Check that with overflow:hidden
and most of the text disappear). 它显示在底部(它在那里结束,文本溢出。检查
overflow:hidden
,大部分文本消失)。 Add a height to the div to make it the size you want. 为div添加一个高度,使其达到您想要的大小。
Short answer: the float:left
. 简答:
float:left
。
To correct that you can add overflow: auto
to #recurring-header-wrapper
要更正,您可以添加
overflow: auto
添加到#recurring-header-wrapper
the floated divs inside cause this. 里面浮动的div导致了这个。 you can clear them.
您可以清除它们。 http://jsfiddle.net/R5YN2/9/
http://jsfiddle.net/R5YN2/9/
Here's the quick fix. 这是快速解决方法。 Basically when you float left the header groups get taken out of the flow unless you clear them with something (an empty div is fine)
基本上,当您向左浮动时,标题组将从流中删除,除非您用某些东西清除它们(空的div可以)
<div id="recurring-header-wrapper">
<div class="recurring-header-group">
<div class="recurring-header-label">Label</div>
<div class="recurring-header-item">Item</div>
</div>
<div class="recurring-header-group">
<div class="recurring-header-label">Label</div>
<div class="recurring-header-item">Item</div>
</div>
<div style="clear:both"></div>
</div>
设置overflow: hidden
在您的重复标头包装器上http://jsfiddle.net/R5YN2/16/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.