运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> div { border: 1px solid #FF0000; } </style> </head> <body> <div id="myDiv">This is some text.</div> <br> <button type="button" onclick="changeMargin()">Change top margin of the div element</button> <br> <br> <div id="myDiv2">This is some text.</div> <br> <button type="button" onclick="changePadding()">Change top padding of the div element</button> <script> function changeMargin() { document.getElementById("myDiv").style.marginTop = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingTop = "100px"; } </script> </body> </html>