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>运行实例 »
点击 "运行实例" 按钮查看在线实例