运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { width: 80%; aspect-ratio: 4/1; border: 1px solid #000000; display: grid; grid-template-columns: 1fr 1fr 1fr; } #container div { width: 50%; aspect-ratio: 1; } </style> </head> <body> <h1>Change justify-self with JavaScript</h1> <div id="container"> <div style="background-color:coral;"></div> <div id="blue" style="background-color:lightblue;"></div> <div style="background-color:pink;"></div> </div> <p>Click the "Try it" button to set the value of the justifySelf property to "right". This makes the blue grid item align right within its own grid cell.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("blue").style.justifySelf = "right"; } </script> </body> </html>