背景定位和背景固定

background-position

body{
    background-image:url('dasf.gif');
    background-repeat:no-repeat;
    background-attachment:fixed;
    background-position:center;
}

1.top left
2.top center
3.top right
4.center left
5.center center
6.center right
7.bottom left
8.bottom right
9.bottom center

如果你規定了一個關鍵詞,那么第二個值將是'center'

默認值:0%0%
我們常用負值;來定位

background-attachment

body{
      background-image:url('dasf.gif');
      background-repeat:no-repeat;
      background-attachment:fixed;
      background-position:center;
}

scroll 默認值  背景圖像會隨著頁面其余部分的滾動而移動.

fixed 當頁面的其余部分滾動時,背景圖像不會移動,

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容