Очистка
Легко очистить float добавив .clearfix к родительскому элементу. Также может быть использован как миксин.
Использование в HTML:
<div class="clearfix">...</div>
Исходный код миксина:
@mixin clearfix() {
&::after {
display: block;
clear: both;
content: "";
}
}
Использование миксина в SCSS:
.element {
@include clearfix;
}
Следующий пример демонстрирует, как использовать очистку. Без очистки div-контейнера кнопки не будут отображаться, что приведёт к нарушению макета.
<div class="bg-info clearfix"> <button type="button" class="btn btn-secondary float-start">Example Button floated left</button> <button type="button" class="btn btn-secondary float-end">Example Button floated right</button> </div>
© 2011–2022 Twitter, Inc.
© 2011–2022 The Bootstrap Authors
Code licensed under the MIT License.
Documentation licensed under the Creative Commons Attribution License v3.0.
https://getbootstrap.com/docs/5.3/helpers/clearfix/