• Resolved nickharambee

    (@nickharambee)


    Because of the admin bar that shows for logged in users, hash links don’t work as I’d like them to, i.e. they work as they should, but the top of the hash div is obscured by the WordPress admin bar. So I am wondering if there is a way that, for logged in users, the position of all hashes can be offset by 28px, so that they show up correctly?

    Presumably, if there is a script that can do this I will need to add it to my functions.php file and wrap it in:

    if (is_user_logged_in()) :
    
    [script here]
    
    endif;

    Thanks,

    Nick

    http://wordpress.org/extend/plugins/better-anchor-links/

Viewing 1 replies (of 1 total)
  • I have the same problem. And I’m thinking it’s more complicated than making an adjustment to the script. I think it’s something the browser simply doesn’t know how to handle.

    When the admin bar is active, the function _admin_bar_bump_cb()
    “pushes down” all the page elements with this css:

    html { margin-top: 28px !important; }
    * html body { margin-top: 28px !important; }

    Presumably this would include our anchor links too if only they had layout properties. Being invisible, they have no “space” in the browser mind.

    The plugin author seems to indicate in another thread that he does not have this problem. I would guess that you and I are using reset css before our main stylesheet. And those who don’t see the problem are not. Or perhaps are not using the admin bar at all.

    ———– FIGURED IT OUT! ——– (thanks for bearing with my train of thought.)

    While typing this message I styled my jump links, giving them “existence” in the mind of the browser dom. This seems to have fixed it in Chrome. YMMV in other browsers:

    a[name] { line-height: 1em; display: inline-block; padding-top: 30px; }

    (It puts a larger than normal gap above your headlines, which may not be ideal, but it looks pretty good in my theme. I’d call it an acceptable “solution.”)

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Better Anchor Links] offsetting hash by 28px to accommodate admin bar for logged in users’ is closed to new replies.