在制作css样式之前,先来准备一份HTML结构代码,如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="css/box.css" rel="stylesheet"/>
</head>
<body>
<div class="box">
<h1>box</h1>
</div>
</body>
</html>
下面为css样式代码
body {
color: #fff;
background: #edf5f9;/*浅蓝灰色*/
position: relative;
}
.box {
background: #2980B9;/*深蓝色*/
position: absolute;
}
h1 {
background: #3498DB;/*浅蓝色*/
}
更改内边距
h1 {
background: #3498DB;
padding: 20px;
}
更改外边距
h1 {
background: #3498DB;
padding: 20px;
margin: 20px;
}
更改边界border
h1 {
background: #3498DB;
padding: 20px;
margin: 20px;
border: 5px solid #fff;
}
通过以上可以得知内容,内外边距,边框之间的位置关系。