Sometimes, we want to use :after to clear floating elements with CSS.
In this article, we’ll look at how to use :after to clear floating elements with CSS.
How to use :after to clear floating elements with CSS?
To use :after to clear floating elements with CSS, we use the :after selector.
For instance, we write
.clearfix:before,
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
to add clear: both
to .clearfix:after
to clear floating elements with the clearfix class.
Conclusion
To use :after to clear floating elements with CSS, we use the :after selector.