曝光臺 注意防騙
網曝天貓店富美金盛家居專營店坑蒙拐騙欺詐消費者
celebrate the new millennium! You’re invited to a party on
December 31, 1999 to celebrate the new millennium! You’re
invited to a party on December 31, 1999 to celebrate the new
millennium! You’re invited to a party on December 31, 1999 to
celebrate the new millennium!
</INVITATION>
12.11.3 background-repeat 屬性
background-repeat 屬性調整背景影像如何在屏幕上平鋪。可指定背景影像為不平鋪或只以水平或垂直方向平鋪。此屬性可
取的值如下:
repeat
repeat-x
repeat-y
no-repeat
例如,要在請諫上僅顯示一頂舞會帽,可設置INVITATION 元素的background-repeat 為no-repeat。圖12-12 顯示的就是
這種情景。例如:
INVITATION { background-image: url(party.gif);
background-repeat: no-repeat }
XML 實用大全
第 383 頁
要在頁面上橫向平鋪而不是向下平鋪,可設置background-repeat 為repeat-x,如下所示。圖12-13 顯示的背景影像是橫
向平鋪而不是向下平鋪。
INVITATION { background-image: url(party.gif);
background-repeat: repeat-x }
圖12-12 未平鋪的背景影像
圖12-13 橫向而不是向下平鋪的背景影像
如要在頁面上向下平鋪而不是橫向平鋪,可按下面的語句將background-repeat 設置為repeat-y。圖12-14 顯示的就是這
種情景。
XML 實用大全
第 384 頁
圖12-14 向下而不是橫向平鋪的背景影像
INVITATION { background-image: url(party.gif);
background-repeat: repeat-y }
12.11.4 background-attachment 屬性
在HTML 中,背景影像是附加到文檔上的。當滾動文檔時,背景影像也隨之滾動。使用background-attachment 屬性,就可
以指定背景只附加于窗口或是窗格上?扇〉闹凳莝croll 和fixed。缺省值是scroll,這就是說,背景附加于文檔而不是
窗口之上。
但是,將background-attachment 設置為fixed,文檔就會滾動,但背景影像不滾動。當不想使此影像平鋪,而對于一般類
型的瀏覽器來說圖像已大到充滿窗口,但大文檔的背景要小時,將此屬性設置為fixed 可能是有用的。這時可編碼如下:
DOCUMENT { background-attachment: fixed;
background-repeat: no-repeat }
無論是IE 5,還是Mozilla 都不支持固定的背景影像。在以后的發行版中有可能增加此功能(CSS1 規范不需要瀏覽器支持固
定背景)。
12.11.5 background-position 屬性
在缺省條件下,背景影像的左上角與它所連接的元素的左上角對齊(見圖12-12)。在多數情況下,這樣就能滿足人們的需要。
但是,在少數情況下,可能還需要其他可能,background-position 就允許人們相對于元素來移動背景。
可使用父元素的寬和高度的百分數、絕對長度或下列六個關鍵字中的兩個來指定偏移量:
top
center
bottom
left
center
right
12.11.5.1 父元素的寬和高度的百分數
百分數能夠把各部分的背景與元素的相應部分緊緊地聯系在一起。x 坐標的百分數范圍從0%(左側)到100%(右側)變化。y
坐標的百分數變化范圍是從0%(頂端)到100%(底部)。例如,下面這條規則把影像的右上角置于INVITATION 的右上角。圖
12-15 為該情況的顯示結果。
INVITATION { background-image: url(party.gif);
XML 實用大全
第 385 頁
background-repeat: no-repeat;
background-position: 100% 0% }
圖12-15 與內容右上角對齊的背景影像
12.11.5.2 絕對長度
絕對長度決定背景的左上角在元素上的絕對位置。下面這條規則把背景影像party.gif 的左上角放置在距元素右邊1 厘米、
左上角下方2 厘米的位置。圖12-16 顯示的就是這種情景。
INVITATION { background-image: url(party.gif);
background-repeat: no-repeat;
background position: lcm 2cm }
圖12-16 距元素右邊1 厘米、左上角下方2 厘米的背景影像
12.11.5.3 關鍵字
XML 實用大全
第 386 頁
top left 和left top 關鍵字與0% 0%相同。top、top center 和center top 與50% 0%相同。right top 和top right 關鍵
字與100% 0%相同。left、left center 和center left 關鍵字與50% 50%相同。right、right center 和center right 關
鍵字與100% 50%相同。bottom left 和left bottom 關鍵字與0% 100%相同。bottom、bottom center 和center bottom 與
50% 100%相同。bottom right 和right bottom 關鍵字與100% 100%相同。圖12-17 將這些關鍵字與元素框上的各位置聯系
在一起了。
top left
left top
0% 0%
top
top center
center top
50% 0%
top right
right top
100% 0%
left
center left
left center
0% 50%
center
center center
50% 50%
right
center right
right center
100% 50%
bottom left
left bottom
0% 100%
bottom
bottom center
center bottom
50% 100%
bottom right
right bottom
100% 100%
圖12-17 背景影像的相對位置
例如,以請諫為例,最好的效果是把影像牢牢地固定于窗口的中間(如圖12-18 所示)。下列是需要的規則:
INVITATION { background-image: url(party.gif);
background-repeat: no-repeat;
background-position: center center }
XML 實用大全
第 387 頁
圖12-18 固定于INVITATION 元素中間的無平鋪背景影像
如果background-attachment 屬性值為fixed,那么影像放置的位置就是窗口邊的相對位置,而不是元素的相對位置。
12.11.6 背景簡略屬性
background 屬性是在一條規則中設置background-color、background-image、background-repeat、background-attachment
中國航空網 www.k6050.com
航空翻譯 www.aviation.cn
本文鏈接地址:
XML實用大全(109)