Stick Menu to Top of Page

  • Unknown's avatar

    Curious how to get the menu (just the menu, not the entire masthead) to stick to the top of the screen when scrolling?
    Can’t seem to find anything.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Hi there,
    Try this CSS code which makes the header section(the menu along with the logo as well, but not the header background image) stick to the top of the page:

    #masthead {
        position: fixed;
        top: 0;
    }

    And let me know if this is what you where looking for.

    If not, then i suppose you just want the menu to stick to the top as it reaches the top of the page when scrolling, right?

    Well… in that case you might be needing some JavaScript to detect how much the page is scrolled so that the menu sticks to the top after it reaches the threshold value of the top of the page.

    And that’s the reason why it can;t be done on WordPress.COM because it does not allow it’s users to edit the underlying JavaScript codes and also does not allow us to add custom scripts to the site.

    This is because, the goal of WordPress.COM is to keep things simple so that we can focus on creating quality content and the technical stuffs are handled by WordPress themselves.

    And also because, sometimes JavaScript codes maybe malicious which may harm your site.

    Read more about JavaScript on WordPress.com here:
    https://en.support.wordpress.com/code/#javascript

    Let me know if this helps :)

  • The topic ‘Stick Menu to Top of Page’ is closed to new replies.