我的页面上有5个div,代码如下:
<!doctype html>
<html lang="en">
<head>
<title>Document</title>
<link rel="stylesheet" href="./style.css" type="text/css"/>
<script src="./jquery.1.8.3.min.js"></script>
</head>
<body>
<div class="col1">行1</div>
<div class="col2">行2</div>
<div class="col3">行3</div>
<div class="col4">行4</div>
<div class="col5">行5</div>
</body>
</html>
style.css
html,body{width:100%;height:100%;}
div{width:50%;float:left;text-align:center;display:block;}
.col1{height:30px;line-height:30px;background-color:yellow;}
.col2{height:30px;line-height:30px;background-color:red;}
.col3{height:30px;line-height:30px;background-color:grey;}
.col4{height:30px;line-height:30px;background-color:green;}
.col5{height:30px;line-height:30px;background-color:blue;}
现在显示的效果
当增加col3的高度为70px的时候,布局变成这样了,如下:
我现在想要这样的效果,如下图:
css3选择器清除奇数div的左浮动即可