英 [?b?kgra?nd]? ?美 [?b?k?ɡra?nd]??

n.(畫等的)背景;底色;背景資料;配樂

復(fù)數(shù): backgrounds

javascript background屬性 語法

作用:設(shè)置所有的背景屬性。

語法:Object.style.background=background-color background-image,background-repeat ,background-attachment ,background-position

參數(shù):background-color ? ?設(shè)置元素的背景色。background-image ? ?設(shè)置背景圖像。background-repeat ? ?設(shè)置背景圖像是否及如何重復(fù)。 background-attachment ? ?背景圖像是否固定或者隨著頁面的其余部分滾動。background-position ? ?設(shè)置背景圖像的起始位置。

javascript background屬性 示例

<html>
<head>
<script type="text/javascript">
function setStyle()
{
document.body.style.background="#FFCC80 url(http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg) repeat-y";
}
</script>
</head>
<body>

<input type="button" onclick="setStyle()"
value="Set background style" />

</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例