小兔网

bootstrap清除浮动的方法:首先打开相应的代码文件;然后通过为父元素添加“.clearfix”类的方法清除浮动,语句如“<div class="clearfix">...</div>”。

bootstrap的清除浮动

本教程操作环境:Windows7系统、bootsrap3.3.7版,Dell G3电脑。

通过为父元素添加 .clearfix 类可以很容易地清除浮动(float)。这里所使用的是 Nicolas Gallagher 创造的 micro clearfix 方式。此类还可以作为 mixin 使用。

使用方法如下:

<!-- Usage as a class --><div class="clearfix">...</div>

.clearfix 类如下:

// Mixin itself.clearfix() {  &:before,  &:after {    content: " ";    display: table;  }  &:after {    clear: both;  }}// Usage as a mixin.element {  .clearfix();}

推荐:《bootstrap视频教程》《css视频教程

以上就是bootstrap的清除浮动的知识。速戳>>知识兔学习精品课!