はじめに
onepage-scrollは、 コンテンツをパララックス風に1ページずつスクロールできるJQueryプラグインです。
2014年06月11日 17時40分
onepage-scrollは、 コンテンツをパララックス風に1ページずつスクロールできるJQueryプラグインです。
作業の前提条件は、下記のとおりです。
| ソフトウエア | バージョン |
|---|---|
| OS | Windows 7 Ultimate 32bit |
| Cygwin | Setup Version 2.831 |
onepage-scrollは、section要素で記述したコンテンツと任意のクラス名をdiv要素に指定するだけで使用できます。
設置に必要なアーカイブをダウンロードし、解凍します。
$ cd /tmp/demo $ wget -q https://github.com/peachananr/onepage-scroll/archive/master.zip $ unzip -q master.zip $ rm -f master.zip $ mv onepage-scroll-master onepage-scroll
onepage-scroll.cssを指定します。
<link rel="stylesheet" href="onepage-scroll/onepage-scroll.css">
jquery.onepage-scroll.min.jsを指定します。
<script src="onepage-scroll/jquery.onepage-scroll.min.js"></script>
section要素と任意のクラス名を指定したdiv要素を使用して、コンテンツを作成します。
<div class="example">
<section>
<p><img src="img/056-01.jpg" alt="/" title="草原"></p>
<p><img src="img/056-03.jpg" alt="/" title="マンハッタン"></p>
</section>
</div>
onepage-scrollのロードを行うJavaScriptを追加します。
<script>
$(function() {
$(".example").onepage_scroll();
});
</script>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>065</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="onepage-scroll/onepage-scroll.css">
<style>
.navbar { background: #888; height: 50px;}
body { background: #888; margin-top: 50px; }
section {
text-align: center;
background: white;
}
section:nth-of-type(1) { background: #ddded3; }
section:nth-of-type(2) { background: #9f945f; }
section:nth-of-type(3) { background: #b29d9d; }
section:nth-of-type(4) { background: #dbd070; }
section:nth-of-type(5) { background: #b8f28c; }
</style>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header"></div>
<div class="navbar-collapse collapse"></div>
</div>
</div>
<div class="example">
<section>
<p><img src="img/056-01.jpg" alt="/" title="草原"></p>
<p><img src="img/056-03.jpg" alt="/" title="マンハッタン"></p>
</section>
<section>
<p><img src="img/056-02.jpg" alt="/" title="レインボーブリッジ"></p>
</section>
<section>
<p><img src="img/056-04.jpg" alt="/" title="向日葵"></p>
</section>
<section>
<p><img src="img/056-05.jpg" alt="/" title="月"></p>
</section>
<section>
<p><img src="img/056-06.jpg" alt="/" title="夜空"></p>
</section>
</div>
<script src="bootstrap.min.js"></script>
<script src="jquery-1.10.2.min.js"></script>
<script src="onepage-scroll/jquery.onepage-scroll.min.js"></script>
<script>
$(function() {
$(".example").onepage_scroll();
});
</script>
</body>
</html>