設定 CSS 網格中自動放置的專案插入方式


使用 grid-auto-flow屬性設定如何將自動放置的專案插入網格。你可以嘗試執行以下程式碼以實現grid-auto-flow屬性

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .container {
            display: grid;
            grid-auto-columns: 50px;
            grid-auto-flow: column;
            grid-gap: 10px;
            background-color: red;
            padding: 10px;
         }
         .container>div {
            background-color: yellow;
            text-align: center;
            padding:10px 0;
            font-size: 20px;
         }
      </style>
   </head>
   <body>
      <div class = "container">
         <div class = "ele1">1</div>
         <div class = "ele2">2</div>
         <div class = "ele3">3</div>
         <div class = "ele4">4</div>
         <div class = "ele5">5</div>
         <div class = "ele6">6</div>
      </div>
   </body>
</html>

更新於: 2020-06-25

107 次瀏覽

開啟你的職業生涯

完成課程即可獲得認證

開始
廣告