运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往空间
<!DOCTYPE html> <html> <head> <style> #myDIV { border: 1px solid black; width: 300px; height: 150px; padding: 35px; background: url('paper.gif') no-repeat; } </style> </head> <body> <h1>Change background-origin with JavaScript</h1> <p>Click the "Try it" button to set the background-origin property of the DIV element to "content-box":</p> <button onclick="myFunction()">Try it</button> <div id="myDIV"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </div> <script> function myFunction() { document.getElementById("myDIV").style.backgroundOrigin = "content-box"; } </script> </body> </html>