単純な視差スクロール技術

親愛なるhabrayuzeryの良い一日。 今日、視差スクロールは一種のトレンドであり、この効果の簡単な実装についてお話したいと思います。 この手法は、 background-position



プロパティの変化率に基づいています。 視差スクロールの効果は、背景がコンテンツよりも遅く移動することです



HTMLマークアップ



"data-type" "data-speed" :

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.













2つのブロックを作成します "data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.













"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









   "data-type"  "data-speed"
      
      



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.









"data-type" "data-speed"



:

<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>





JavaScript, data-type



.





CSS

id #home #about





#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }





home-bg.jpg

30efa81c4067e1a308e5bd8b431



about-bg.jpg

ネットクライブ



:

#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }







JavaScript - jQuery

data-type="background"



:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });





.scroll()



.each()



, :

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });





:

var yPos = -($(window).scrollTop() / $bgobj.data('speed'));





ネットクライブ



background-position coords



:

var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });







:

$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });







.












All Articles