使用 CSS 在行之間顯示 Flex 專案,其中包含空格


與值 space-between 結合使用 justify-content 屬性,可在行之間新增空格。

示例

你可以嘗試執行以下程式碼來實現 space-between 值 -

實際演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: red;
            justify-content: space-between;
         }
         .mycontainer > div {
            background-color: white;
            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

137 次檢視

開啟你的 職業生涯

完成課程,獲取認證

開始行動
廣告