use*_*495 4 html css twitter-bootstrap
<div style="float:left;">
column 1
</div>
<div style="float:left;">
column 2
</div>
<div style="clear:both;"></div>
Run Code Online (Sandbox Code Playgroud)
我习惯写作clear:both.但我在Twitter Bootstrap中听到有一种叫做"clearfix"的东西?我应该/应该使用哪个元素"clearfix"?
art*_*ung 10
你可能只需要这样做:
<div class="container">
<div class="row">
<div class="span6">column 1</div>
<div class="span6">column 2</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
clearfix 不应该是必要的.
使用css你可以简单地使用after psudeo
.class1:after, .class2:after //append as many as you like
{
clear:both;
*zoom:1;
height:0;
visibility: hidden;
display:block;
}
alternative(providing children are not using the position selector)
(parent-elemts){overflow:hidden;}//bit of a quick fix!
Run Code Online (Sandbox Code Playgroud)
将不需要的标记保留在html文件之外
编辑:对不起!由于某种原因,添加评论按钮或upvote按钮今晚对我不起作用.
要附上我的回答来回答您的其他问题:
twitter bootstrap你说使用.clearfix类,它类似于我在下面提供的css,但是他们的方法需要添加到元素中,即:"element class ="clearfix"或者类似,其中css pseduo我们不需要将这些额外的代码添加到我们的文档中.请注意,并非所有浏览器都支持css pseduo.
| 归档时间: |
|
| 查看次数: |
26602 次 |
| 最近记录: |