方法:1、使用background-attachment屬性,語法“background-attachment:fixed”;2、使用background-repeat屬性,語法“background-repeat:no-repeat”。
本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
背景圖片不重復不平鋪,可以這樣設定背景:
1、這樣背景圖片就會固定住,不會因頁面滾動而重復。
<body style="background-image: url("圖片文件地址"); background-attachment: fixed;">
2、使圖在任何大小的屏幕都不會顯示重復,可以這樣設定背景(圖像不平鋪):
<body style="background-image: url("圖片文件地址"); background-repeat:no-repeat;">
推薦學習:css視頻教程