Html 在相同高度向左/向右拉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18513372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pull-left/right at the same height
提问by Brigitte Fellner
I am using bootstrap and want to have two columns, one left, one right. The only problem is, it is not at the same height, but it should. I could do that with margin negative, but that doesn't feel right. I also found the class='clearfix', but that does not work. What is the solution of this easy problem?
我正在使用引导程序并希望有两列,一左一右。唯一的问题是,它不在同一高度,但它应该。我可以在保证金为负的情况下做到这一点,但这感觉不对。我还发现了 class='clearfix',但这不起作用。这个简单的问题的解决方案是什么?
HTML
HTML
<div class="span6 pull-left"> left some content here </div> <div class="span6 pull-right"> right content here </div>
<div class="span6 pull-left"> left some content here </div> <div class="span6 pull-right"> right content here </div>
回答by htxryan
In Bootstrap, pull = float.
在 Bootstrap 中,pull = float。
The problem here is that the span divs are too wide. When you float left and right, you will see this behavior if the width of the divs is greater than the width of the container.
这里的问题是跨度 div 太宽了。当您左右浮动时,如果 div 的宽度大于容器的宽度,您将看到这种行为。
In Bootstrap, you don't actually need to do this. If the width of your grid is 12, you can simply do what you've done, with two 6-width spans (no pulling or floating required).
在 Bootstrap 中,您实际上不需要这样做。如果您的网格宽度为 12,您可以简单地执行您所做的操作,使用两个 6 宽度的跨度(不需要拉动或浮动)。
<div class="span6">
left some content here
</div>
<div class="span6">
right content here
</div>