A Cool Way to Clear Floats When using Compass

There are a variety of ways to clear floats with working with html, one way being to create a div with style: clear: both after the last floated element. A more elegant way, when working with Compass, is to use clearfix. Here’s how to go about it.

@import "compass/utilities/general/clearfix"
...
.some-element-to-clear-floats-for {
  @include clearfix();
  ...
}

References

Compass Clearfix | Compass Documentation. http://compass-style.org/reference/compass/utilities/general/clearfix/. 9/1/2017.

Leave a Reply

Your email address will not be published. Required fields are marked *