运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <style> #myDIV { width: 300px; height: 300px; background: lightblue url('smiley.gif') no-repeat; color: white; overflow: auto; } </style> <body> <h1>HTML Style Object</h1> <h2>The backgroundAttachment Property</h2> <p>Click the radio buttons and scroll the DIV element to see the effect of the background-attachment property:</p> <form name="myForm"> <input type="radio" name="myAtt" value="scroll" onclick="myFunction()" checked>scroll <input type="radio" name="myAtt" value="local" onclick="myFunction()">local </form> <div id="myDIV"> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> <h1>Hello</h1> </div> <script> function myFunction() { if (document.forms["myForm"]["myAtt"][0].checked) { document.getElementById("myDIV").style.backgroundAttachment = "scroll"; } else { document.getElementById("myDIV").style.backgroundAttachment = "local"; } } </script> </body> </html>