Home >Web Front-end >CSS Tutorial >How to use clear in css
The clear attribute allows elements to leave the floating flow, that is, clear the float. Its usage is as follows: left: clear the left floating element right: clear the right floating element both: clear all floating elements
Usage of clear in CSS
The role of clear attribute
The clear attribute allows elements to escape from the The float flow created by the float element is the float that is cleared.
Usage
The clear attribute has two main values:
Application Example
<code class="css">/* 清除左侧的浮动元素 */ .container { clear: left; } /* 清除右侧的浮动元素 */ .container { clear: right; } /* 清除所有浮动元素 */ .container { clear: both; }</code>
When to use
The clear attribute is usually used in the following situations:
Note
The above is the detailed content of How to use clear in css. For more information, please follow other related articles on the PHP Chinese website!