css clear属性如何用
发布时间:09/01 来源:未知 浏览:
关键词:
css clear属性如何用?
clear 属性规定元素的哪一侧不同意其他浮动元素。
语法:
clear:left|right|both|none|inherit;
属性值:
● left:在左侧不同意浮动元素。
● right:在右侧不同意浮动元素。
● both:在摆布两侧均不同意浮动元素。
● none:默许值。同意浮动元素显现在两侧。
● inherit:规定应当从父元素继承 clear 属性的值。
说明:
clear 属性定义了元素的哪边上不同意显现浮动元素。在 CSS1 和 CSS2 中,这是通过主动为清除元素(即设定了 clear 属性的元素)增添上外边距实现的。在 CSS2.1 中,会在元素上外边距之上增添清除空间,而外边距本身并不改动。
不管哪一种改动,终究结果都一样,假如声明为左边或右侧清除,会使元素的上外边框边界恰好在该边上浮动元素的下外边距边界之下。
注释:所有主流阅读器都支撑 clear 属性。任何版本的 Internet Explorer (包罗 IE8)都不支撑属性值 "inherit"。
css clear属性 示例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> img { float:left; } p.clear { clear:both; } </style> </head> <body> <img src="logocss.gif" width="95" height="84" /> <p>This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.</p> <p>This is also some text. This is also some text. This is also some text. This is also some text. This is also some text.</p> <br> <p>使用clear:both清除浮动:</p> <img src="logocss.gif" width="95" height="84" /> <p>This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.</p> <p class="clear">This is also some text. This is also some text. This is also some text. This is also some text. This is also some text. </p> </body> </html>
结果图:
以上就是css clear属性如何用的具体内容,更多请关注百分百源码网其它相关文章!