Skip to main content Skip to docs navigation

التنظيف (Clearfix)

قم بتنظيف المحتوى العائم داخل الحاوية بسرعة وسهولة عن طريق إضافة أداة الـ clearfix.

قم بتنظيف الـ float بسهولة عن طريق إضافة .clearfix إلى العنصر الأب. يمكن استخدامه أيضاً كـ mixin.

الاستخدام في HTML:

<div class="clearfix">...</div>

كود المصدر الخاص بالـ mixin:

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

استخدام الـ mixin في SCSS:

.element {
  @include clearfix;
}

يوضح المثال التالي كيفية استخدام الـ clearfix. بدون الـ clearfix، لن يمتد الـ div المحيط حول الأزرار، مما سيؤدي إلى تخطيط مكسور.

html
<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>