CSS justify-content 屬性 center 值的作用


使用值 justify-content屬性center 將 flex-items 對齊到中心。

示例

您可以嘗試執行以下程式碼來實現中心值 −

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: red;
            justify-content: center;
         }
         .mycontainer > div {
            background-color: orange;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
            width: 100px;
            margin: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Quiz</h1>
      <div class = "mycontainer">
         <div>Q1</div>
         <div>Q2</div>
         <div>Q3</div>
         <div>Q4</div>
      </div>
   </body>
</html>

更新時間:04-Jul-2020

180 次瀏覽

開啟您的職業生涯

完成課程,獲取認證

立刻開始
廣告
© . All rights reserved.