- Foundation Tutorial
- Foundation - Home
- Foundation - Overview
- Foundation - Installation
- Foundation - Starter Projects
- Foundation - Kitchen Sink
- Foundation General
- Foundation - Global Styles
- Foundation - Sass
- Foundation - JavaScript
- Foundation - JavaScript Utilities
- Foundation - Media Queries
- Foundation - The Grid
- Foundation - Flex Grid
- Foundation - Forms
- Foundation - Visibility Classes
- Foundation - Base Typography
- Foundation - Typography Helpers
- Foundation - Basic Controls
- Foundation - Navigation
- Foundation - Containers
- Foundation - Media
- Foundation - Plugins
- Foundation SASS
- Foundation - Sass Functions
- Foundation - Sass Mixins
- Foundation Libraries
- Foundation - Motion UI
- Foundation Useful Resources
- Foundation - Quick Guide
- Foundation - Useful Resources
- Foundation - Discussion
Interchange Use with Background Images
Description
To set the background image, use the data-interchange attribute inside the <div> tag. You can pass the image path to set the background-image property of the matching rule.
Example
The following example demonstrates the use of interchange with background image in 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> <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>
Output
Let us carry out the following steps to see how the above given code works −
Save the above given html code background_image.html file.
Open this HTML file in a browser, an output is displayed as shown below.
foundation_plugins.htm
Advertisements
To Continue Learning Please Login
Login with Google