主頁
CSS
CSS Flexbox
彈性專案
Tryit: 使用 align-self: center
執行 ❯
建立您
自己的
網站
×
改變方向
儲存程式碼
改變主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> .flex-container { display: flex; height: 200px; background-color: #f1f1f1; } .flex-container > div { background-color: DodgerBlue; color: white; width: 100px; margin: 10px; text-align: center; line-height: 75px; font-size: 30px; } </style> </head> <body> <h1>The align-self Property</h1> <p>The "align-self: center;" aligns the selected flex item in the middle of the container:</p> <div class="flex-container"> <div>1</div> <div>2</div> <div style="align-self: center">3</div> <div>4</div> </div> <p>The align-self property overrides the align-items property of the container.</p> </body> </html>