头闻号

周春生

美容材料及用具|其他彩妆化学品|汽车香水|水晶工艺品|摆、挂饰物|座垫、座套

首页 > 新闻中心 > 科技常识:clearfix:after清除浮动的用法及测试代码
科技常识:clearfix:after清除浮动的用法及测试代码
发布时间:2024-09-22 04:22:53        浏览次数:5        返回列表

今天小编跟大家讲解下有关clearfix:after清除浮动的用法及测试代码 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关clearfix:after清除浮动的用法及测试代码 的相关资料,希望小伙伴们看了有所帮助。

今天回顾一下css中的清除浮动 复制代码代码如下: .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden} .clearfix{*+height:1%;} .clearfix:after {visibility: hidden;display: block;font-size: 0;content:"";clear: both;height: 0;} .clearfix{*zoom:1;}//只针对IE6/7 测试代码: 复制代码代码如下: <html > <head> <title> new document </title> <meta name="generator"content="editplus"/> <meta name="author"content=""/> <meta name="keywords"content=""/> <meta name="description"content=""/> </head> <body> <style type="text/css"> .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden} .clearfix{*+height:1%;} .box{ background:#111;width:500px; position:relative;} .l{float:left; background:#333;width:200px; height:100px;} .r{float:right;background:#666;width:200px; height:200px;} .s{width:100px; height:100px;background:#999;position:absolute;right:-50px;;} </style> <div class="box clearfix"> <div class="l">left</div> <div class="r">right</div> <div class="s">absolute</div> </div> </body> </html> :after 伪元素在元素之后添加内容。这个伪元素允许创作人员在元素内容的最后面插入生成内容。默认地 这个伪元素是行内元素 不过可以使用属性display改变这一点。

来源:爱蒂网