背景圖片
取值
<!--
background-image:url(路徑);引入背景圖片
background-repeat: 背景重復(fù)
取值:
no-repeat 不重復(fù)
repeat-x 在x軸方向重復(fù)
repeat-y 在y軸方向重復(fù)
repeat 默認(rèn)值 重復(fù)
background-size: 背景圖片的大小
取值:
value1(寬度) value2(高)
value1%(寬度) value2%(高)
cover 覆蓋 將背景圖片等比例縮放直到背景圖片能覆蓋元素的所有區(qū)域
contain 包含 將背景圖片等比例縮放,直到背景圖片碰到右邊或下邊的時(shí)候停止縮放
background-attachment: 背景圖片固定
取值:
scroll 默認(rèn)值,會(huì)隨著文檔的滾動(dòng)而滾動(dòng)
fixed 背景圖片固定,不會(huì)隨著文檔的滾動(dòng)而滾動(dòng)
-->
樣式
<html>
<head>
<meta charset="utf-8"/>
<title>背景圖片</title>
<style>
.dv1{
width:1200px;
height:600px;
border:1px solid #000;
margin:20px auto;
/**添加背景圖片**/
background-image:url(images/team1.jpg);
/**不讓背景圖片重復(fù)*/
background-repeat:no-repeat;/*不重復(fù)*/
/*在x軸重復(fù)*/
/* background-repeat:repeat-x; *//*在x軸重復(fù)*/
/*在y軸重復(fù)*/
/* background-repeat:repeat-y; *//*在x軸重復(fù)*/
/**改變背景圖片的尺寸*/
/* background-size:
value1(寬) value2(高);
value1% value2%
cover 覆蓋 將背景圖片等比例縮放直到背景圖片能覆蓋元素的所有區(qū)域
*/
/*background-size:1200px 600px;*/
background-size:contain;
background-attachment:fixed;
/*背景圖的固定
background-attachment:
取值:
scroll 默認(rèn)值,會(huì)隨著文檔的滾動(dòng)而滾動(dòng)
fixed 背景圖片固定,不會(huì)隨著文檔的滾動(dòng)而滾動(dòng)
*/
}
</style>
</head>
<body>
<!--
background-image:url(路徑);引入背景圖片
background-repeat: 背景重復(fù)
取值:
no-repeat 不重復(fù)
repeat-x 在x軸方向重復(fù)
repeat-y 在y軸方向重復(fù)
repeat 默認(rèn)值 重復(fù)
background-size: 背景圖片的大小
取值:
value1(寬度) value2(高)
value1%(寬度) value2%(高)
cover 覆蓋 將背景圖片等比例縮放直到背景圖片能覆蓋元素的所有區(qū)域
contain 包含 將背景圖片等比例縮放,直到背景圖片碰到右邊或下邊的時(shí)候停止縮放
background-attachment: 背景圖片固定
取值:
scroll 默認(rèn)值,會(huì)隨著文檔的滾動(dòng)而滾動(dòng)
fixed 背景圖片固定,不會(huì)隨著文檔的滾動(dòng)而滾動(dòng)
-->
<div class='dv1'>
<p>dffdgggffghgn</p>
</div>
<div class='dv2'></div>
</body>
</html>