CSS background 屬性詳解

來源:互聯網
上載者:User

標籤:no-repeat   http   方式   use   parameter   ace   als   where   背景圖片   

CSS background Property

文法:

background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;

Note: If one of the properties in the shorthand declaration is the bg-size property, you must use a / (slash) to separate it from the bg-position property, e.g. background:url(smiley.gif) 10px 20px/50px 50px; will result in a background image, positioned 10 pixels from the left, 20 pixels from the top, and the size of the image will be 50 pixels wide and 50 pixels high.

Note: If using multiple background-image sources but also want a background-color, the background-color parameter needs to be last in the list.

background-color

background-color

Default value: transparent

The background-color property sets the background color of an element.

The background of an element is the total size of the element, including padding and border (but not the margin)(包括內邊距和邊框).

background-position

The background-position property sets the starting position of a background image(背景圖片的開始位置).

Tip: By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.

background-size

The background-size property specifies the size of the background images.

文法:

background-size: auto|length|cover|contain|initial|inherit; 

background-repeat

The background-repeat property sets if/how(背景圖片的重複/迴圈方式) a background image will be repeated.

By default, a background-image is repeated both vertically and horizontally.

Tip: The background image is placed according to the background-position property. If no background-position is specified, the image is always placed at the element‘s top left corner.

background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial|inherit;

background-origin

Default value: padding-box

The background-origin property specifies where the background image is positioned. 

Note: If the background-attachment property is set to "fixed", this property has no effect.

background-origin: padding-box|border-box|content-box|initial|inherit;

background-clip

The background-clip property specifies the painting area of the background. 

background-clip: border-box|padding-box|content-box|initial|inherit;

background-attachment

The background-attachment property sets whether a background image is fixed or scrolls with the rest of the page.

background-attachment: scroll|fixed|local|initial|inherit;

 

CSS background 屬性詳解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.