目录

按屏幕大小显示(Show by Screen Size)

描述 (Description)

  • 它通过在页面上使用.show类显示基于设备的元素,用户正在查看该元素。

  • 您可以使用show-for-smallshow-for-small小型设备的内容,对于中型设备,使用show-for-medium类,对于大型设备,可以使用show-for-large类。

例子 (Example)

以下示例演示了在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://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></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>

输出 (Output)

让我们执行以下步骤,看看上面给出的代码是如何工作的 -

  • 保存上面给出的html代码show_screen.html文件。

  • 在浏览器中打开此HTML文件,输出显示如下。

新页面打开
↑回到顶部↑
WIKI教程 @2018