运行 ❯
获取您自己的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { width: 100%; height: 300px; margin: 10px 0; border: solid black 1px; display: flex; flex-wrap: wrap; } #container > div { height: 10%; aspect-ratio: 2/1; margin: 2px; background-color: lightblue; } </style> </head> <body> <h1>Change place-content property with JavaScript</h1> <p>Click the "Try it" button to change the place-content values of the flexbox container:</p> <button onclick="myFunction()">Try it</button> <div id="container"></div> <script> function myFunction() { document.getElementById("container").style.placeContent = "end space-around"; } let containerEl = document.getElementById("container"); for(let i=0; i<17; i++){ let divEl = document.createElement("div"); containerEl.appendChild(divEl); } </script> </body> </html>