clearfix hack for floats #css
✓ Published0🌍 Public
TTimeBandit
Last edited Oct 29, 2018
Created on Oct 29, 2018
A CSS code snippet demonstrates the clearfix hack, a technique that prevents a containing element from collapsing to zero height when its children are floated. The example uses the `.clearfix::after` pseudo-element with `content`, `clear`, and `display` properties in a SCSS file. This approach renders a hidden table element after the container, which clears the floats and restores the container’s height. The code shows the standard modern clearfix pattern, relying on CSS pseudo-elements and the `clear` property rather than JavaScript libraries or external rendering APIs.
AI-generated description