Utilisation d'échange avec les images d'arrière-plan

La description

Pour définir l'image d'arrière-plan, utilisez l' attribut d' échange de données dans la balise <div>. Vous pouvez transmettre le chemin de l'image pour définir la propriété background-image de la règle correspondante.

Exemple

L'exemple suivant illustre l'utilisation de l'échange avec l'image d'arrière-plan dans 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>

Production

Exécutons les étapes suivantes pour voir comment fonctionne le code donné ci-dessus -

  • Enregistrez le code html ci-dessus background_image.html fichier.

  • Ouvrez ce fichier HTML dans un navigateur, une sortie s'affiche comme indiqué ci-dessous.