Foundation - 与图像交互使用
说明
使用图像交互,您可以根据屏幕尺寸设置图像大小,即大、中或小。图像在小屏幕设备上显示得较小。要确定要为用户设备提供哪个图像,请使用 CSS 媒体查询。
示例
以下示例演示了 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>
输出
让我们执行以下步骤来查看上述代码的工作原理 −
保存上述 html 代码 use_images.html 文件。
在浏览器中打开此 HTML 文件,将显示如下所示的输出。

foundation_plugins.html