• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Duplicate Create a standard anchor class

Stuart Wright

Well-known member
#1
For people like us at AVForums who use a sticky header, when a page opens at an anchor, the window is scrolled to the wrong location. It's offset by the height of the sticky header.
E.g. http://www.avforums.com/threads/header-bug-on-both-menus.1860101/#post-20361575
If all anchors in Xenforo had the same class, we could modify it to adjust the position so the user arrived at them in exactly the right position on the page.
So please consider adding a class to all anchors.
Thanks.
 

Mike

XenForo developer
Staff member
#3
Yeah, I don't really understand. An #anchor is simply referring to an element with that ID. It's the browser that's responsible for the scrolling for the most part (though we do actually have an extra check that does some scrolling to account for certain buggy browsers). If you have a sticky header, it's virtually always going to be something that has to be handled specially.
 

EQnoble

Well-known member
#4
I agree.

I did something custom at one point a while ago that offset the position of # and had to work around it and come up with something that fixes the issue, however this needs to be slightly tweaked pending the styling of the site it is being applied to so I think this is something not suited to be stock. Adding a class would not be the solution as the real problem is the sticky content hiding your starting point so you would really just need to address the offset and not worry about styling and classes.
 

Rob

Well-known member
#8
I have the same issue Stuart and also using a fixed header.
Surely jQuery can select all id's starting with "post-" and modify them? Same for other content if they are similarly prefixed.
 

Chris D

XenForo developer
Staff member
#9
jQuery can certainly dynamically add a class which may help.

Here's an example I've just executed on this page using the browser console:

upload_2014-2-20_8-37-3.png

But in terms of adding styling to that, I'm not sure how useful that would be. Those elements are the list elements which are the posts on the page. They are also the anchor links. Manipulating the styling of those would also manipulate the style of posts.
 

EQnoble

Well-known member
#10
I have the same issue Stuart and also using a fixed header.
Surely jQuery can select all id's starting with "post-" and modify them? Same for other content if they are similarly prefixed.
Yes exactly and it is quite simple and actually you don't even need jquery for this one.