<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"utf-8"
>
<
style
type=
"text/css"
>
div{
background-image:
url(
"1.png");
width:
500px;
height:
500px;
/* 不平铺 */
background-repeat:
no-repeat;
/* 横向平铺 */
/* background-repeat: repeat-x; */
/* 纵向平铺 */
/* background-repeat: repeat-y; */
background-color:
pink;
/* background-position: top right; */
/* 图片位置 */
/* background-position: 30px 40px; */
/* 背景固定显示 */
background-attachment:
fixed;
}
<
/
style
>
</
head
>
<
body
>
<
div
>
</
div
>
</
body
>
</
html
>
图片的联写的步骤也是第二个方法
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
div{ | |
width:500px; | |
height:500px; | |
background: url("1.png") red no-repeat 30px 40px; | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
</div> | |
</body> | |
</html |