代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .box{ width: 200px; height: 200px; background-color: pink; } </style> </head> <body> <div class="box"></div> <script> let box = document.querySelector('.box') box.style.backgroundColor = 'red' box.style.width = '500px' box.style.height = '500px' </script> </body> </html>
效果图:
web API-DOM-修改标签样式-style
于 2023-07-17 00:07:56 首次发布