I tried placing the sidebar etc. in a fixed position and automatically tracking it.
I often see things like automatically tracking sidebars on homepages and blogs, but I've wanted to try it for a while, so I gave it a try.
- < script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >< / script >
- <script>
- $(function($) {
- var tab = $("#sidebar"),
- offset = tab.offset();
- $(window).scroll(function () {
- if($(window).scrollTop() > offset.top) {
- tab.addClass("fixed");
- } else {
- tab.removeClass("fixed");
- }
- });
- });
- </script>
The indentation may be incorrect...
Line 5, this time I used #sidebar, but enter the ID and class of the part you want to fix here.
For now, I inserted the above into the head tag and added the following to the style sheet.
- .fixed {
- position : fixed ;
- top : 20px ;
- }
It's surprisingly easy.
The blog below was very helpful.
thank you.