 
						HTML
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <divid="cbp-fbscroller"class="cbp-fbscroller">    <nav>        <ahref="#fbsection1"class="cbp-fbcurrent">Section 1</a>        <ahref="#fbsection2">Section 2</a>        <ahref="#fbsection3">Section 3</a>        <ahref="#fbsection4">Section 4</a>        <ahref="#fbsection5">Section 5</a>    </nav>        <sectionid="fbsection1"></section>        <sectionid="fbsection2"></section>        <sectionid="fbsection3"></section>        <sectionid="fbsection4"></section>        <sectionid="fbsection5"></section></div> | 
CSS
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* Set all parents to full height */html,body,.container,.cbp-fbscroller,.cbp-fbscroller section {    height:100%;}/* The nav is fixed on the right side  and we center it by translating it 50% (we don't know it's height so we can't use the negative margin trick) */.cbp-fbscroller > nav {    position:fixed;    z-index:9999;    right:100px;    top:50%;    -webkit-transform:translateY(-50%);    -moz-transform:translateY(-50%);    -ms-transform:translateY(-50%);    transform:translateY(-50%);}.cbp-fbscroller > nav a {    display:block;    position:relative;    color:transparent;    height:50px;}.cbp-fbscroller > nav a:after {    content:'';    position:absolute;    width:24px;    height:24px;    border-radius:50%;    border:4pxsolid#fff;}.cbp-fbscroller > nav a:hover:after {    background:rgba(255,255,255,0.6);}.cbp-fbscroller > nav a.cbp-fbcurrent:after {    background:#fff;}/* background-attachment does the trick */.cbp-fbscroller section {    position:relative;    background-position:topcenter;    background-repeat:no-repeat;    background-size:cover;    background-attachment:fixed;}#fbsection1{    background-image:url(../images/1.jpg);}#fbsection2{    background-image:url(../images/2.jpg);}#fbsection3{    background-image:url(../images/3.jpg);}#fbsection4{    background-image:url(../images/4.jpg);}#fbsection5{    background-image:url(../images/5.jpg); | 
JavaScript
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | varcbpFixedScrollLayout = (function() {    // cache and initialize some values    varconfig = {        // the cbp-fbscroller′s sections        $sections : $( '#cbp-fbscroller > section'),        // the navigation links        $navlinks : $( '#cbp-fbscroller > nav:first > a'),        // index of current link / section        currentLink : 0,        // the body element        $body : $( 'html, body'),        // the body animation speed        animspeed : 650,        // the body animation easing (jquery easing)        animeasing : 'easeInOutExpo'    };    functioninit() {        // click on a navigation link: the body is scrolled to the position of the respective section        config.$navlinks.on( 'click', function() {            scrollAnim( config.$sections.eq( $( this).index() ).offset().top );            returnfalse;        } );        // 2 waypoints defined:        // First one when we scroll down: the current navigation link gets updated.         // A `new section′ is reached when it occupies more than 70% of the viewport        // Second one when we scroll up: the current navigation link gets updated.         // A `new section′ is reached when it occupies more than 70% of the viewport        config.$sections.waypoint( function( direction ) {            if( direction === 'down') { changeNav( $( this) ); }        }, { offset: '30%'} ).waypoint( function( direction ) {            if( direction === 'up') { changeNav( $( this) ); }        }, { offset: '-30%'} );        // on window resize: the body is scrolled to the position of the current section        $( window ).on( 'debouncedresize', function() {            scrollAnim( config.$sections.eq( config.currentLink ).offset().top );        } );            }    // update the current navigation link    functionchangeNav( $section ) {        config.$navlinks.eq( config.currentLink ).removeClass( 'cbp-fbcurrent');        config.currentLink = $section.index( 'section');        config.$navlinks.eq( config.currentLink ).addClass( 'cbp-fbcurrent');    }    // function to scroll / animate the body    functionscrollAnim( top ) {        config.$body.stop().animate( { scrollTop : top }, config.animspeed, config.animeasing );    }    return{ init : init };})(); | 
特别申明:
			本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
			本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
			如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com