background
英[ˈbækgraʊnd] 美[ˈbækˌɡraʊnd]
n.(畫等的)背景;底色;背景資料;配樂
複數: backgrounds
attachment
英[əˈtætʃmənt] 美[əˈtætʃmənt]
n.(用電子郵件發送的),附屬電子郵件,附屬物;依戀,依附;扣押財產<法>逮捕,扣押(人,財產)
複數:attachments
#javascript backgroundAttachment屬性 語法
作用:設定背景圖像是否固定或隨著頁面的其餘部分滾動。
語法:Object.style.backgroundAttachment=scroll|fixed
註解:請設定可用的背景顏色,這樣的話,假如背景圖像不可用,頁面也可獲得良好的視覺效果。
javascript backgroundAttachment屬性 範例
<html> <head> <style type="text/css"> body { background-color="#FFCC80"; background-image:url(http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg); } p { color:white; } </style> <script type="text/javascript"> function changeAttachment() { document.body.style.backgroundAttachment="fixed"; } </script> </head> <body> <input type="button" onclick="changeAttachment()" value="Set background-image to be fixed" /> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p> </body> </html>
執行實例 »
點擊 "執行實例" 按鈕查看線上實例