Skip to content

Clearfix

When floats are used for layouts—they need a clearfix solution. This helps prevent layout problems caused by the elements being removed from the block context of the surrounding elements.

Cleared Floats

This example shows two floated elements wrapped in an element with a solid red border. In the top version where the floats are cleared, the red element wraps around the elements. In the second example—the parent element is collapsed and the two floated elements sit outside of it. It should be noted you don’t have to clear floated elements that are inside another floated element.

vue
<template>
  <div v-cf>
    <div v-fl></div>
    <div v-fl></div>
  </div>
</template>

UnCleared Floats

vue
<template>
  <div>
    <div v-fl></div>
    <div v-fl></div>
  </div>
</template>

See Also

Reference