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
You need to put position: fixed; on the div element. That will anchor it to the viewport.
Use position fixed. Position fixed makes it so that an element stays at it's specified place even if the user scrolls up or down.
Just replace #sticky_div's_name_here with the name of your div, i.e. if your div was <div id="example"> you would put #example { position: sticky; top: 0; } .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With