在使用bootstrap时避免不了使用了float等布局,这个时候下面元素可通过添加.clearfix类,快速轻松地清除容器内浮动的内容(使元素换行呈现)。把clearfix 添加到父元素上就可以实现目的。例如:

<div class="float-right"></div>
<div class="clearfix"><span>我的内容!</span></div>

其内部定义如下:


@mixin clearfix() {
  &::after {
    display: block;
    content: "";
    clear: both;
  }
}

.element {
  @include clearfix;
}

特此记录学习bootstrap的过程。