与图像一起使用(Use with Images)

优质
小牛编辑
126浏览
2023-12-01

描述 (Description)

使用图像交换,您可以根据屏幕大小设置图像大小,即大,中或小。 图像在小屏幕设备上显示得更小。 要确定要为其提供图像的用户设备,请使用CSS媒体查询。

例子 (Example)

以下示例演示了在Foundation中使用交换图像的方法 -

<!DOCTYPE html>
<html>
   <head>
      <title>Foundation Template</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.css">
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation.min.js"></script>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>
   </head>
   <body>
      <h2>Example of use with images</h2>
      <img data-interchange = "[/foundation/images/foundation-plugin/small.jpg, (default)], 
         [/foundation/images/foundation-plugin/small.jpg, (small)], 
         [/foundation/images/foundation-plugin/medium.jpg, (medium)]">
      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>