运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <style> #myDIV { width: 220px; height: 300px; border: 1px solid black; display: flex; } </style> <body> <p>Click the "Try it" button to set the flex property of ALL DIV elements inside the "myDIV" element:</p> <button onclick="myFunction()">Try it</button> <div id="myDIV"> <div style="background-color:coral;">RED</div> <div style="background-color:lightblue;">BLUE</div> <div style="background-color:lightgreen;">Green div with more content.</div> </div> <script> function myFunction() { const x = document.getElementById("myDIV"); const y = x.getElementsByTagName("DIV"); let i = 0; for (i; i < y.length; i++) { y[i].style.msFlex = "1"; // IE10 y[i].style.flex = "1"; } } </script> </body> </html>