The clear attribute in CSS is used to control the area around the floating element and specify the positioning method of subsequent elements. It has three values: left, right, and both, which are used to move from the left, right or left side of the floating element respectively. The positioning of subsequent elements begins on the left and right sides.
clear
What does clear mean in CSS?
The clear property is used to control the area around floating elements. It specifies how subsequent elements are positioned when a floated element is encountered.
Detailed explanation:
Floating elements will break away from the normal document flow and be arranged along the edges of their parent elements. The clear attribute allows subsequent elements to skip over floated elements instead of surrounding them.
There are three clear values:
Usage example:
<code class="css"><div class="container"> <div class="float-left">浮动元素</div> <div class="clear"></div> <div>后续元素</div> </div></code>
In the above example, the .clear class has the clear: both; attribute applied. This will cause subsequent elements to start to the left and right of the floated element, creating a gap so that subsequent elements will not be wrapped by the floated element.
The above is the detailed content of What does clear mean in css. For more information, please follow other related articles on the PHP Chinese website!