NatChen

Once you have chosen the road of life, you have to be brave enough to go to the end and never look back.

:after伪类+content经典应用举例

:after伪类+content 清除浮动的影响

.box{padding:10px; background:gray;}
.l{float:left;}

<div class="box">
	<img class="l" src="http://image/imagemm1.jpg" />
</div>
.fix:after{display:block; content:"clear"; height:0; clear:both; overflow:hidden; visibility:hidden;}

:after伪类+content 让大小不固定图片垂直居中

.pic_box{width:300px; height:300px; background-color:#beceeb; font-size:0; *font-size:200px; text-align:center;}
 .pic_box img{vertical-align:middle;}
 .pic_box:after{display:inline-block; width:0; height:100%; content:"center"; vertical-align:middle; overflow:hidden;}
<div class="pic_box">
    <img data-src="http://image/mm1.jpg" />
</div>
posted @ 2017-11-23 11:52  NatChen  阅读(317)  评论(0编辑  收藏  举报