基金會 - 按螢幕大小顯示



描述

  • 它基於裝置來顯示頁面上的元素,這是透過使用 .show 類完成的,使用者檢視該元素。

  • 你可以使用 show-for-small 類顯示適用於小型裝置的內容,使用 show-for-medium 類顯示適用於中型裝置的內容,而使用 show-for-large 類顯示適用於大型裝置的內容。

範例

以下範例演示了在 Foundation 中使用 .show 類 −

<!doctype html>
   <head>
      <meta charset = "utf-8" />
      <meta http-equiv = "x-ua-compatible" content = "ie = edge" />
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />

      <title>Show by Screen Size</title>

      <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://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>
   </head>

   <body>
      <h2>Show by Screen Size Example</h2>
      <p class = "show-for-small">This line appears on small or medium screen.</p>
      <p class = "show-for-medium">This line appears on medium screen or larger.</p>
      <p class = "show-for-large">This line appears on large screen or larger.</p>
   </body>
</html>

輸出

按照以下步驟,瞭解上面提供的程式碼是如何工作的 −

  • 儲存上面提供的 html 程式碼 show_screen.html 檔案。

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

foundation_visibility_classes.htm
廣告