编辑下面的代码:【加编码】
<html> <head> <style type="text/css"> body { background:#f3f3f3 url('img_tree.png') no-repeat right top; } </style> <script> function displayResult() { document.body.style.backgroundAttachment="fixed"; } </script> </head> <body> <button type="button" onclick="displayResult()">Set background image to be fixed</button> <br> <h1>Hello World!</h1> <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>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂