Alex Rivera | Logout

Always visible div while scrolling

Asked 2012-01-24T13:22:15.063
27

On my aspx page, I have two left and right portions. I want to show always left side (which is actually a 'div' containig treeview) while scrolling the right side (which are actual contents of page). Thanks

Edit
Report

1 Answer

21

Hi I found the best solution! As always JQUERY saving my life !!

Just put a Div called as you wan, I've chosen the same in the example below: #scrollingDiv.

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script>
    $().ready(function() {
        var $scrollingDiv = $("#scrollingDiv");

        $(window).scroll(function(){            
            $scrollingDiv
                .stop()
                .animate({"marginTop": ($(window).scrollTop() )}, "slow" );         
        });
    });
</script>

I took that code from a website, it works and it's pretty easy to understand.

answered 2013-04-10T10:30:54.357

Your Answer