案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<style type="text/css">
4
body
5
{
6
background-color:#FFCC80;
7
background-image:url(/img/eg_bg_desert.jpg);
8
background-repeat:no-repeat;
9
background-attachment:fixed;
10
}
11
</style>
12
<script type="text/javascript">
13
function changePosition()
14
{
15
document.body.style.backgroundPosition="bottom center";
16
}
17
</script>
18
</head>
19
<body>
20
21
<input type="button" onclick="changePosition()" value="Change background-image position" />
22
<p><b>Note:</b> For this to work in Mozilla, the background-attachment property must be set to "fixed".</p>
23
</body>
24
</html>
25