一、margin
英文意思:页边的空白
即使设置每个模块div的外白宽度
1、父模块宽度为1000,三个漂浮子模块宽度各位400,加起来超过父模块,那么第三个就会换行
<style>
#cont{
width: 1000px;
height: 2000px;
background: blue;
}
div{
width: 400px;
height: 200px;
background: yellow;
float: left;
}
</style>
<body>
<div id="cont">
<div id="test1">1</div>
<div>2</div>
<div>3</div>
</div>
</body>
二、border
1、border3要素
2、border画一个三角形
<style>
div{
width: 1000px;
height: 1000px;
}
#test{
width: 0px;
height: 0px;
border-top: 500px solid;
border-right: 500px solid;
border-bottom: 500px solid;
border-left: 500px solid blue;
}
</style>
<body>
<div>
<div id=test></div>
</div>
</body>
延申:
1、让其余几个三角形透明
2、用css画一个圣诞树
三、paddin
内边距,设置方式同上
注意padding是会让background变大的
四、综合应用
margin、border、padding都加上后实际面积有多大?
这些参数之和
五、margin实现居中
auto
六、margin重叠现象研究