你的位置:首页 > 网页设计

[网页设计]清除浮动1


<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Author" content="胡超">
<title>super胡</title>
<style>
.news {
background-color: gray;
border: solid 1px black;

}
.news img {
float: left;
}

.news p {
float: right;
}
.clearfix:after{
content: ".";
display:block;
height:0px; /*一、该方法中必须为需要清除浮动元素的伪对象中设置 height:0,否则该元素会比实际高出若干像素;*/
clear: both;
visibility: hidden;
}

.clearfix {
/* 触发 hasLayout */
zoom: 1;
}
</style>
</head>
<body>
<div >
<img src="7v/1318240446520.jpg" />
<p>some text</p>
</div>

</body>
</html>