MyBB Community Forums

Full Version: Problem using fixed header – need to offset viewport
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
No, I added it to the postbit url tag.

I tried it on the a name - still not working
Strange, it worked for me..
Which one did you use?
I just added padding to the unique <a> tag, but I see it doesn't work in Chrome (Firefox and IE are OK though). I'm going to try some other things to see if they'll work in all browsers.
I am using Opera, Good to hear on the IE Big Grin
Well, it's good that both you and Brad are using the two browsers that it doesn't work with Toungue
Solved.

For anyone who is interested....



The solution requires latest jQuery and jQuery scrollTo.


		<script>
		jQuery(document).ready(function() {
			var pid = window.location.hash.replace('#pid', '');
		    var headerHeight = $('#header').height() + $('#header-bottom-cap').height() + 10;
		    $('a').click(function(){
		        var hashEle = $(this).attr('href').split('#');
		        if (hashEle.length > 1) {
		            if (hashEle[1] == 'top') {
		                $('body, html').animate({
		                    scrollTop: $("#post" + "pid" + ">tr>td").offset().top
		                },500);
		            } else {
		            jQuery('body, html').animate({
		                scrollTop: $('#'+ hashEle[1]).offset().top - headerHeight
		            },500);
		            }
		        };
		    })
		    
			hashname = window.location.hash.replace('#', '');
			elem = $('#' + hashname);
			if(hashname.length > 1) {
			    if(hashname == 'pid' + *) {
			    $('body, html').animate({
			            scrollTop: $("#post" + "pid" + ">tr>td").offset().top
			        },200); 
			    } else {
			     $('body, html').animate({
			            scrollTop: $(elem).offset().top - headerHeight
			        },500);
			 }
			};
		});
		</script>

Enjoy Smile!

EDIT: Some old code leftover Toungue
Okay, try this:

If your postbit (the entire thing) isn't already wrapped in a div, do so. Create/add to that div's class (it's needed to make position:absolute not go full retard):

position: relative;

Next, add to either a class or inline styling, to the unique <a> tag in the postbit template:

display: block; position: absolute; top: -30px; left: -10000px;

And adjust the top offset accordingly. It seems to work in IE(9?), FF, Chrome and Opera without any negative side effects (that I can see, anyways).
There are other solutions though Jason, and not all of us use JQuery.

I will look to see if Scriptaculous can do it if a css solution is not working.
Thank you Scoutie, I shall hurry off and test.

IT WORKS!!!

* Leefish goes to test in many browsers.

thank you
Pages: 1 2 3 4 5