1. 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

Discussion in 'Closed Suggestions' started by Stuart Wright, Feb 19, 2014.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    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.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    By nature of what an anchor in the URL is, it should be unique and map to exactly one element on the page.
     
  3. Mike

    Mike XenForo Developer Staff Member

    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.
     
  4. EQnoble

    EQnoble Well-Known Member

    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.
     
  5. Chris D

    Chris D XenForo Developer Staff Member

  6. Stuart Wright

    Stuart Wright Well-Known Member

    Indeed Jeremy, but that doesn't stop us from giving them all the same class.
     
  7. Stuart Wright

    Stuart Wright Well-Known Member

  8. Rob

    Rob Well-Known Member

    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.
     
  9. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
  10. EQnoble

    EQnoble Well-Known Member

    Yes exactly and it is quite simple and actually you don't even need jquery for this one.
     
  11. Mike

    Mike XenForo Developer Staff Member

Share This Page