©
This document uses PHP Chinese website manual Release
通过添加一个clearfix实用程序,快速轻松地清除容器中的浮动内容。
通过添加.clearfix 到父元素可轻松清除floats 。也可以用作混音。
<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>