写给自己:
1.使用auto设置元素的水平居中
2.margin负值
3.body是经常设置的样式:margin:0px;
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Margin的使用技巧</title>
<style type="text/css">
/* body是经常设置的值 */
body{
margin: 0;
}
.box{
width:200px;
height: 200px;
background-color: gold;
/* 1.margin负值 */
/* 0px 元素贴边 */
/* 正值 元素向右移 */
/* 负值 元素向左移 */
margin-left: -90px;
/* 2.使用auto设置元素的水平居中 */
/* margin: 50px auto 100px auto; */
/* 简写如下 */
/* margin: 100px auto 100px; */
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>