天天看點

CSS background-color 、image 背景圖檔

預設值:transparent  透明

适用于:所有元素

繼承性:無

動畫性:是

計算值:指定值

<dl><dt></dt></dl>

設定或檢索對象的背景顔色。

當同時定義了背景顔色和背景圖像時,背景圖像覆寫在背景顔色之上。

對應的腳本特性為backgroundColor。

背景圖檔 background-image

預設值:none

動畫性:否

<dl></dl>

<dt>none: 無背景圖。 </dt>

<dt></dt>

設定或檢索對象的背景圖像。

如果定義了多組背景圖,且背景圖之間有重疊,寫在前面的将會蓋在寫在後面的圖像之上。

對應的腳本特性為backgroundImage。

background-image : url(“http://static.criteo.net/flash/icon/nai_small.png”);  // 全URL路徑

background-image : url(“/flash/icon/nai_small.png”);  // 根路徑

background-image : url(“../nai_small.png”) ;  // 相對于css檔案的路徑

background-image : url(../nai_small.png) ;  //不寫引号

background-image : url(‘../nai_small.png’) ; // 單引号

背景重複  background-repeat

&lt;repeat-style&gt; = repeat-x | repeat-y | [repeat | no-repeat | space | round]{1,2}

預設值:repeat

<dt>repeat-x:背景圖像在橫向上平鋪 </dt>

<dt>repeat-y: 背景圖像在縱向上平鋪 </dt>

<dt>repeat: 背景圖像在橫向和縱向平鋪 </dt>

<dt>no-repeat: 背景圖像不平鋪 </dt>

<dt>round: 背景圖像自動縮放直到适應且填充滿整個容器。(CSS3) </dt>

<dt>space: 背景圖像以相同的間距平鋪且填充滿整個容器或某個方向。(CSS3)</dt>

允許提供2個參數,如果提供全部2個參數,第1個用于橫向,第二個用于縱向。

如果隻提供1個參數,則用于橫向和縱向。特殊值repeat-x和repeat-y除外,因為repeat-x相當于repeat no-repeat,repeat-y相當于no-repeat repeat,即其實repeat-x和repeat-y等價于提供了2個參數值

對應的腳本特性為backgroundRepeat。

背景跟着内容滾動 background-attachment

&lt;attachment&gt; = fixed | scroll | local

預設值:scroll

<dt>fixed: 背景圖像相對于窗體固定。 </dt>

<dt>scroll: 背景圖像相對于元素固定,也就是說當元素内容滾動時背景圖像不會跟着滾動,因為背景圖像總是要跟着元素本身。但會随元素的祖先元素或窗體一起滾動。 </dt>

<dt>local: 背景圖像相對于元素内容固定,也就是說當元素随元素滾動時背景圖像也會跟着滾動,因為背景圖像總是要跟着内容。(CSS3)</dt>

對應的腳本特性為backgroundAttachment。

開始做,堅持做,重複做

繼續閱讀