运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #myDIV { position: absolute; background-color: coral; color: white; } </style> </head> <body> <h1>Change right property with JavaScript</h1> <p>Click the "Try it" button to position the DIV element 100 pixels from the right edge:</p> <p><strong>Note:</strong> If the position property is set to "static", the right property has no effect.</p> <button onclick="myFunction()">Try it</button> <div id="myDIV"> <h1>myDIV</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.right = "100px"; } </script> </body> </html>