background
英[?b?kgra?nd]? ?美[?b?k?ɡra?nd]??
n.(畫等的)背景;底色;背景資料;配樂
複數(shù): backgrounds
attachment
英[??t?t?m?nt]? ?美[??t?t?m?nt]??
n.(用電子郵件發(fā)送的),附屬電子郵件,附屬物;依戀,依附;扣押財(cái)產(chǎn)<法>逮捕,扣押(人,財(cái)產(chǎn))
複數(shù):attachments
#javascript backgroundAttachment屬性 語法
作用:設(shè)定背景圖像是否固定或隨著頁面的其餘部分滾動(dòng)。
語法:Object.style.backgroundAttachment=scroll|fixed
註解:請(qǐng)?jiān)O(shè)定可用的背景顏色,這樣的話,假如背景圖像不可用,頁面也可獲得良好的視覺效果。
javascript backgroundAttachment屬性 範(fàn)例
<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>
執(zhí)行實(shí)例 ?
點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例