<html> <head> <style type="text/css"> body { background-color:#FFCC80; background-image:url(/static/images/bg_desert.jpg); background-repeat:no-repeat; background-attachment:fixed; } </style> <script type="text/javascript"> function changePosition() { document.body.style.backgroundPositionY="bottom"; } </script> </head> <body> <input type="button" onclick="changePosition()" value="Change background-image's y-position" /> <p><b>Note:</b> For this to work in Mozilla, the background-attachment property must be set to "fixed".</p> </body> </html>
结果:
编辑上面的代码,点击查看结果。
yige.org
- 试一个