首頁  >  文章  >  web前端  >  CSS 自我對齊屬性

CSS 自我對齊屬性

WBOY
WBOY轉載
2023-08-30 19:01:061039瀏覽

CSS 自我对齐属性

使用align-self 屬性設定任何彈性項目的對齊方式。您可以嘗試執行以下程式碼來實作CSS的align-self屬性

範例

現場示範

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            height: 300px;
            background-color: orange;
         }
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 90px;
            font-size: 40px;
            width: 100px;
            margin: 50px;
         }
      </style>
   </head>
   <body>
      <h1>Quiz</h1>
      <div class = "mycontainer">
         <div>Q1</div>
         <div>Q2</div>
         <div>Q3</div>
         <div style = "align-self: center">Q4</div>
         <div>Q5</div>
      </div>
   </body>
</html>

以上是CSS 自我對齊屬性的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除