Home >Web Front-end >CSS Tutorial >In css, the role of clear:both
clear:both is a property in CSS that solves the problem of overlapping floating elements. Its function is to specify a height for the current element so that it can accommodate all floating elements. Make sure there are no floating elements overlapping below the current element.
The role of clear:both in CSS
clear:both
is a CSS Attribute, used to solve the problem of overlapping of floating elements on block-level elements.
Floating elements will break out of the document flow, while block-level elements will occupy the entire width. When a block-level element contains a floated element, the floated element may overlap part of the block-level element's content.
clear:both
The role of the clear:both
The way to use
clear:both
<code class="css">.container { clear: both; }</code>
It is worth noting that ,
clear:both can only clear floating elements above the current element. If you need to clear floated elements on multiple elements, you need to use the
clear:both attribute on each element. ###The above is the detailed content of In css, the role of clear:both. For more information, please follow other related articles on the PHP Chinese website!