Foundation-interchange-background-images
提供:Dev Guides
背景画像でのインターチェンジの使用
説明
背景画像を設定するには、<div>タグ内で_data-interchange_属性を使用します。 イメージパスを渡して、一致ルールの_background-image_プロパティを設定できます。
例
次の例は、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 finddevguides</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_imagel ファイルを保存します。
- このHTMLファイルをブラウザで開くと、次のように出力が表示されます。