Home >Web Front-end >CSS Tutorial >How to close float in css
The way to turn off floating in CSS is to add the clear attribute to the element and set the attribute value to none, such as [clear:both;]. The clear attribute specifies that no other floating elements are allowed on a certain side of the element.
The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.
There is an attribute clear in css, which specifies which side of the element does not allow other floating elements.
Commonly used attribute values are:
left Floating elements are not allowed on the left side.
#right No floating elements are allowed on the right side.
#both Floating elements are not allowed on the left and right sides.
#none Default value. Allows floated elements to appear on both sides.
#inherit Specifies that the value of the clear attribute should be inherited from the parent element.
A small example:
<html> <head> <style type="text/css"> img { float:left; clear:both; } </style> </head> <body> <img src="/i/eg_smile.gif" /> <img src="/i/eg_smile.gif" /> </body> </html>
Related video sharing: css video tutorial
The above is the detailed content of How to close float in css. For more information, please follow other related articles on the PHP Chinese website!