Flex Grid 響應式調整



說明

如果未給出 flex grid 中一列的明確大小,那麼它將自動調整列的大小。對於較小的螢幕,請使用 .small-* 類。medium-expandlarge-expand 類用於擴充套件行為。

例項

以下示例演示了在 Foundation 中使用 響應式調整

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">

      <title>Foundation Template</title>
      <!-- Compressed CSS -->
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" crossorigin="anonymous">

      <!-- Compressed JavaScript -->
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>
   </head>

   <body>
      <h2>Example of Flex Grid</h2>

      <div class = "row">
         <div class = "small-6 large-expand columns" style = "background-color:#8BD6EE;">
            First column
         </div>

         <div class = "small-6 large-expand columns" style = "background-color:#C0B0F0;">
            Second column
         </div>

         <div class = "small-6 large-expand columns" style = "background-color:#8BD6EE;">
            Third column
         </div>

         <div class = "small-6 large-expand columns" style = "background-color:#C0B0F0;">
            Forth column
         </div>

         <div class = "small-6 large-expand columns" style = "background-color:#8BD6EE;">
            Fifth column
         </div>

         <div class = "small-6 large-expand columns" style = "background-color:#C0B0F0;">
            Sixth column
         </div>
      </div>

   </body>
</html>

輸出

讓我們執行以下步驟來檢視上面給出的程式碼是如何工作的 −

  • 儲存上面給出的 html 程式碼 responsive_adjustment.html 檔案。

  • 在瀏覽器中開啟此 HTML 檔案,如下所示顯示輸出。

自動堆疊

自動堆疊是用於響應式調整行為的速記類。.[size]-unstack 類用於預設情況下堆疊一行中的所有列,並在較大的螢幕中解壓。

例項

以下示例演示了在 Foundation 中使用 自動堆疊

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">

      <title>Foundation Template</title>
      <!-- Compressed CSS -->
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" crossorigin="anonymous">

      <!-- Compressed JavaScript -->
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>
   </head>

   <body>
      <h2>Example of Flex Grid</h2>

      <div class = "row medium-unstack">
         <div class = "columns" style = "background-color:#FF6347;">First</div>
         <div class = "columns" style = "background-color:#7B68EE;">Second</div>
         <div class = "columns" style = "background-color:#FF6347;">Third</div>
         <div class = "columns" style = "background-color:#7B68EE;">Forth</div>
         <div class = "columns" style = "background-color:#FF6347;">Fifth</div>
         <div class = "columns" style = "background-color:#7B68EE;">Sixth</div>
      </div>

   </body>
</html>

輸出

讓我們執行以下步驟來檢視上面給出的程式碼是如何工作的 −

  • 儲存上面給出的 html 程式碼 automatic_stacking.html 檔案。

  • 在瀏覽器中開啟此 HTML 檔案,如下所示顯示輸出。

foundation_flex_grid.htm
廣告
© . All rights reserved.