百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>CSS教程> css clear属性如何用
分享文章到:

css clear属性如何用

发布时间:09/01 来源:未知 浏览: 关键词:
css clear属性指定元素的左侧或右侧上不同意显现浮动元素。可用于实现浮动的清除,解决浮动规划带来的一些问题。

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>

结果图:

1.jpg

以上就是css clear属性如何用的具体内容,更多请关注百分百源码网其它相关文章!

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有151人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板