运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #main { width: 350px; height: 100px; border: 1px solid #c3c3c3; display: flex; } #main div:nth-of-type(1) {flex-grow: 1;} #main div:nth-of-type(2) {flex-grow: 1;} #main div:nth-of-type(3) {flex-grow: 1;} </style> </head> <body> <div id="main"> <div style="background-color:coral;"></div> <div style="background-color:lightblue;" id="myBlueDiv"></div> <div style="background-color:khaki;"></div> </div> <p>Click the "Try it" button to set the value of the flexGrow property to "5" for the blue div element</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("myBlueDiv").style.flexGrow = "5"; } </script> </body> </html>