使用JavaScript中的padding属性设置元素的填充。您可以尝试运行以下代码以使用JavaScript添加元素的填充-
<!DOCTYPE html> <html> <head> <style> #box { border: 2px solid #FF0000; width: 150px; height: 70px; } </style> </head> <body> <div id = "box">This is demo text.</div> <br><br> <button type = "button" onclick = "display()">Add Padding</button> <script> function display() { document.getElementById("box").style.padding = "20px 30px 10px 50px"; } </script> </body> </html>