运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #main { width: 220px; height: 300px; border: 1px solid black; display: flex; align-items: flex-start; } #main div { flex: 1; } #myBlueDiv { align-self: center; } </style> </head> <body> <h1>HTML Style Object</h1> <h2>The alignSelf Property</h2> <div id="main"> <div style="background-color:coral;">RED</div> <div style="background-color:lightblue;" id="myBlueDiv">BLUE</div> <div style="background-color:lightgreen;">Green div with more content.</div> </div> <p>Click the button to set the value of the alignSelf property to "stretch"</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("myBlueDiv").style.alignSelf = "stretch"; } </script> </body> </html>