HTML DOM backgroundRepeat 屬性
定義和用法
backgroundRepeat 屬性設(shè)置背景圖像是否及如何重復(fù)。
語法:
Object.style.backgroundRepeat=repeat_value
參數(shù) | 描述 |
---|---|
repeat | 默認(rèn)。背景圖像將在垂直方向和水平方向重復(fù)。 |
repeat-x | 背景圖像將在水平方向重復(fù)。 |
repeat-y | 背景圖像將在垂直方向重復(fù)。 |
no-repeat | 背景圖像將僅顯示一次。 |
實(shí)例
本例僅在 y 軸重復(fù)背景圖像:
<html>
<head>
<style type="text/css">
body
{
background-color:#FFCC80;
background-image:url(bgdesert.jpg);
}
</style>
<script type="text/javascript">
function changeRepeat()
{
document.body.style.backgroundRepeat="repeat-y";
}
</script>
</head>
<body>
<input type="button" onclick="changeRepeat()"
value="Repeat background-image only on the y-axis" />
</body>
</html>