abstract:浮动在网页布局时经常使用,是为了实现类似似word中“图文混排”的效果。浮动会脱离文档的普通流。float属性常用的值有有三种1)left;2)righ;3)none。为维持页面的有序,需要使用清除浮动。清除浮动:clear属性的值:1)left;2)righ;3)both 例子如下:<!DOCTYPE html><html><head> <meta ch
浮动在网页布局时经常使用,是为了实现类似似word中“图文混排”的效果。浮动会脱离文档的普通流。float属性常用的值有有三种1)left;2)righ;3)none。为维持页面的有序,需要使用清除浮动。清除浮动:clear属性的值:1)left;2)righ;3)both 例子如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type=“text/css”>
.bigbox{width: 200px;height: 200px;margin: 0px auto;text-align: center;line-height:100px;}
.box1{width:100px;height: 100px;background-color: pink;float:left;}
.box2{width:100px;height: 100px;background-color: yellow;float:right;}
.box3{width:100px;height: 100px;background-color: red;float:left;}
.box4{width:100px;height: 100px;background-color: green;float: right;}
.clear{clear: both;}
</style>
</head>
<body>
<div class="bigbox">
<div class="box1">块1</div>
<div class="box2">块2</div>
<div class="clear"></div>
<div class="box3">块3</div>
<div class="box4">块4</div>
</div>
</body>
</html>