<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
list-style: none; /*去除小圆点*/
text-decoration: none; /*去除下划线*/
}
.div{
width: 100%;
height: 40px;
background: gainsboro;
}
.center{
width: 1000px;
height: 40px;
margin: 0 auto;
background: lightsalmon;
}
.div1{
width: 100px;
height: 40px;
background: palevioletred;
float: left;
}
.div2{
width: 100px;
height: 40px;
background: chartreuse;
float: right;
}
</style>
</head>
<body>
<div class="div">
<ul class="center">
<div class="div1">
1
</div>
<div class="div2">
2
</div>
</ul>
</div>
</body>
</html>
float : left
float : right
clear : both 清除浮动 一定要记得清除浮动
overflow : auto 溢出撑大
overflow : hidden 溢出隐藏
最好是用浮动布好局在进行添加内容,
那样可以清晰的看到那一块出现出现布局问题