css 双伪元素清除浮动

<!DOCTYPE html>

<html >

<head>

<meta charset="UTF-8">

<title>双伪元素清除浮动</title>

<style type="text/css">

/* 声明清除浮动的样式 */

.clearfix:before,

.clearfix:after {

content: "";

display: table;

}

.clearfix:after {

clear: both;

}

/* ie6 7 专门清除浮动的样式*/

.clearfix {

*zoom:1;

}

.one {

width: 500px;

border: 1px solid red;

}

.damao {

float: left;

width: 200px;

height: 200px;

background-color: purple;

}

.ermao {

float: left;

width: 250px;

height: 250px;

background-color: skyblue;

}

.two {

width: 700px;

height: 150px;

background-color: #000;

}

</style>

</head>

<body>

<div class="one clearfix">

<div class="damao"></div>

<div class="ermao"></div>

</div>

<div class="two"></div>

</body>

</html>