运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> button { margin-bottom: 10px; } #myDIV { background-color: lightblue; border: solid black 1px; } .redDiv { background-color: rgb(239, 135, 88); text-align: center; } </style> </head> <body> <h1>Change margin-block with JavaScript</h1> <p>Click the "Try it" button to change the margin-block of the blue DIV element:</p> <button onclick="myFunction()">Try it</button> <div class="redDiv">div</div> <div id="myDIV"> This is my DIV element. </div> <div class="redDiv">div</div> <script> function myFunction() { document.getElementById("myDIV").style.marginBlock = "50px 20px"; } </script> </body> </html>