Banner (left/right) will scrolling (up/down) when scrolling page

by Monday, June 16, 2014 0 comments
Html:
<html>
    <head>
        <title>Scrolling</title>
        <style>
            .container{ 
                position: relative;
                margin: 0 auto;
                width: 1000px;
                height: 2000px;
            }
        </style>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <body>
        <div class="container"></div>
    </body>
</html>


Jquery:
$(function(){
    $('html').append(
        '<div id="ban_left" class="ban_scroll">CONTENT BANNER LEFT </div>',
        '<div id="ban_right" class="ban_scroll">CONTENT BANNER RIGHT</div>'
    );
    $(window).scroll(function(){
        var $toado_old=0;
        var $toado_curr=$(window).scrollTop();
        $('.ban_scroll').stop().animate({'top':$toado_curr-$toado_old+50},400);//TOP 100px
        $toado_old=$toado_curr;
    });
});

Css:
div#ban_left {
       left: 1px;
}
div#ban_right {
       right: 1px;
}
div.ban_scroll {
   width: 100px;
       height: 300px;
       position: absolute;
       top: 50px;
       background: #ff0;
       z-index: -1;
       cursor: pointer;
}


Unknown

Developer

Notes này để lưu lại những vấn đề, những công việc trong quá trình làm việc gặp phải, để sau này khi gặp phải thì có thể giải quyết nhanh chóng. Ngoài ra thì còn những thông tin khác để giúp lưu lại những kiến thức đã biết.

0 comments:

Post a Comment