在我第一次进行背景图片的插入时上网搜了很多内容,但是都没有得到想要的方法,现在我将自己多次尝试后的插入方法分享给大家:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
* {
margin: 0;
border: 0;
}
.div {
width: 100%;
height: 700px;
background-image: url(img/headers.jpg);
background-size: cover;
background-attachment: fixed; /*决定背景图片是否固定*/
background-position: center; /*决定背景图片是否居中*/
}
</style>
</head>
<body>
<div></div>
</body>
</html>
以上代码中最重要的就是background的三个属性。