365体育备用网址报道HTML DOM backgroundAttachment 属性_365体育备用网址官网资讯

JavaScript/dom_obj_style.HTML">HTML DOM Style 对象

定义和用法

backgroundAttachment 属性设置背景图像是否固定或者随着页面的其余部分滚动。

语法:

Object.style.backgroundAttachment=scroll|fixed

提示和注释

提示:请设置一种可用的背景颜色,这样的话,假如背景图像不可用,页面也可获得良好的视觉效果。

实例

本例设置在点击按钮后把背景图像设置为固定(不滚动):

<html>
<head>
<style type="text/CSS">
body
{
background-color="#FFCC80";
background-image:url(/VuDLSELEBujrNRbDYkRYOjNNCSfRONV.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>

TIY

PHP?filename=hdom_style_backgroundattachment">把背景图像设置为固定
------分隔线----------------------------

公布评论 (94人察看0条评论)
请自觉遵守互联网相关的政策法规,严禁公布色情、暴力、反动的言论。
用户名: 验证码: 点击我更换水果老虎机老鹰版
最新评论