1.重復(fù)背景
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>Setting the canvas background</TITLE>
<STYLE type="text/css">
BODY { background: url("http://××。com/marble.png") }
</STYLE>
</HEAD>
<BODY>
<P>My background is marble.
</BODY>
</HTML>
2.重復(fù)背景
BODY { background-image: url("marble.gif") }
P { background-image: none }
3.在x或Y方向上重復(fù)
BODY {
background: white url("pendant.gif");
background-repeat: repeat-y;
background-position: center;
}
4.在x或Y方向上重復(fù)時當(dāng)拖動滾動條時,定位不移動
BODY {
background: red url("pendant.gif");
background-repeat: repeat-y;
background-attachment: fixed;
}
綜合上述: 背景CSS可以簡寫為 background: #ff0000 url("images/bg.gif") no-repeat left center;