CSS background-attachment 屬性
實例
如何指定一個固定的背景圖像:
body
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
}
標籤定義及使用說明
background-attachment設置背景圖像是否固定或者隨著頁面的其餘部分滾動。
默認值: | scroll |
---|---|
繼承: | no |
版本: | CSS1 |
JavaScript 語法: | object object.style.backgroundAttachment="fixed" |
流覽器支持
表格中的數字表示支持該屬性的第一個流覽器版本號。
緊跟在 -webkit-, -ms- 或 -moz- 前的數字為支持該首碼屬性的第一個流覽器版本號。
屬性 | |||||
---|---|---|---|---|---|
background-attachment | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
注意: Internet Explorer 8 及其更早版本的流覽器不支持多個背景圖像在一個元素。
屬性值
值 | 描述 |
---|---|
scroll | 背景圖片隨著頁面的滾動而滾動,這是默認的。 |
fixed | 背景圖片不會隨著頁面的滾動而滾動。 |
local | 背景圖片會隨著元素內容的滾動而滾動。 |
initial | 設置該屬性的默認值。 閱讀關於 initial 內容 |
inherit | 指定 background-attachment 的設置應該從父元素繼承。 閱讀關於 inherit 內容 |
相關文章
CSS 教學: CSS Background