- Foundation 概览
- Foundation - 全局样式
- Foundation - Sass
- Foundation - JavaScript
- Foundation - JavaScript 实用工具
- Foundation - 媒体查询
- Foundation - 网格
- Foundation - Flex 网格
- Foundation - 表单
- Foundation - 可见性类
- Foundation - 基本排版
- Foundation - 排版助手
- Foundation - 基本控件
- Foundation - 导航
- Foundation - 容器
- Foundation - 媒体
- Foundation - 插件
- Foundation SASS
- Foundation - Sass 函数
- Foundation - Sass Mixins
- Foundation 库
- Foundation - Motion UI
- Foundation 实用资源
- Foundation - 快速指南
- Foundation - 实用资源
- Foundation - 讨论
使用背景图片进行交换
说明
要设置背景图片,可以在 <div> 标记中使用 data-interchange 属性。你可以传递图片路径来设置相匹配规则的 background-image 属性。
示例
以下示例演示了在 Foundation 中使用带有背景图片的 interchange −
<!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>
<div data-interchange = "[/foundation/images/foundation-plugin/smallback.jpg, (small)],
[/foundation/images/foundation-plugin/mediumback.jpg, (medium)],
[/foundation/images/foundation-plugin/background.jpg, (large)]">
<h2>Welcome to TutorialsPoint</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book.
</p>
</div>
<script>
$(document).ready(function() {
$(document).foundation();
})
</script>
</body>
</html>
输出
让我们执行以下步骤,看看上面给出的代码是如何工作的 −
将上面给出的 html 代码保存到 background_image.html 文件中。
在浏览器中打开此 HTML 文件,显示的输出如下。
foundation_plugins.htm
广告