in English

清除修复

通过添加 clearfix 实用程序快速轻松地清除容器内的浮动内容。

float通过添加.clearfix 到父元素轻松清除s 。也可以用作mixin。

<div class="clearfix">...</div>
// Mixin itself
@mixin clearfix() {
  &::after {
    display: block;
    content: "";
    clear: both;
  }
}

// Usage as a mixin
.element {
  @include clearfix;
}

以下示例显示了如何使用 clearfix。如果没有 clearfix,包装 div 将不会跨越按钮,这会导致布局损坏。

<div class="bg-info clearfix">
  <button type="button" class="btn btn-secondary float-left">Example Button floated left</button>
  <button type="button" class="btn btn-secondary float-right">Example Button floated right</button>
</div>