一、背景设置
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>背景设置</title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<div>春眠不觉晓,处处闻啼鸟</div>
</body>
</html>
css:
div{
width: 1200px;
height: 800px;
border: 1px red solid;
/*background-color: yellow;
background-image: url("dm.jpg"),url("dm1.jpg");
background-repeat: no-repeat,repeat-y;
background-position: 0px 0px ;
background-size: 50% 50% ;*/
/*顺序可以任意*/
/*size*/
/*多背景*/
background: url("dm.jpg") 0px 0px/200px 200px no-repeat,url("dm1.jpg") right/300px 300px repeat-y;
}
三、外边距
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>外边距</title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<div>
<div class="div1">我是div1</div>
<div class="div2">我是div2</div></div>
</body>
</html>
css:
div{
width: 200px;
height: 200px;
background: red;
border: 1px gold solid;
}
.div1{
margin-left: 100px;
margin-top: 100px;
margin-bottom: 50px
}
.div2{
background: blue;
margin-left: 300px;
margin-top: -200px;
}
三、外边距坑
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>外边距的坑</title>
<style type="text/css">
div{
width: 200px;
height: 200px;
}
.div1{
background-color: red;
margin-bottom: 50px;
border: 1px #eef0f0 solid;
}
.div2{
margin-top: 51px;
background-color: blue;
}
.hezi{
width: 400px;
height: 200px;
background-color: #eef0f0;
padding: 50px;
margin:
}
</style>
</head>
<body>
<div class="div1">
<div class="div2">
<div class="hezi"></div>
</div>
</div>
</body>
</html>
四、内边距
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>外边距</title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<div >我是div1</div>
</body>
</html>
css:
div{
height: 200px;
background: red;
padding-left: 50px;
padding-top: 50px;
}