background屬性

background屬性包含background-image屬性,是在一個聲明中設置所有的背景屬性。

連background-image在內,background屬性包含以下:

background-color    規定要使用的背景顏色。1

background-position    規定背景圖像的位置。1

background-size    規定背景圖片的尺寸。3

background-repeat    規定如何重複背景圖像。1

background-origin       規定背景圖片的定位區域。3

background-clip    規定背景的繪製區域。3

background-attachment    規定背景圖像是否固定或者隨着頁面的其餘部分滾動。1

background-image    規定要使用的背景圖像。1

inherit    規定應該從父元素繼承 background 屬性的設置。1

通常在寫css的時候,一般都直接用background做全局設置,不單獨去設置。

用background做全局設置時,要將所有背景屬性寫在一個聲明中

body { background: red }

p { background: url("index.png") 40% / 10em gray  round fixed border-box; }

分拆寫法如下

body {

    background-color: red;

    background-position: 0% 0%;

    background-size: auto;

    background-repeat: repeat;

    background-clip: border-box;

    background-origin: padding-box;

    background-attachment: scroll;

    background-image: none }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章