Add horizontal navigation bar to page header using HTML/CSS

Sam_Asbeck July 8, 2020

We're trying to create a horizontal HTML navigation bar in our Confluence space, following the basic tutorial here: https://www.w3schools.com/howto/howto_css_dropdown_navbar.asp

When we edit our space's stylesheet and insert the HTML into an HTML macro it works perfectly. However, this option is not scalable, as we would have to enter this HTML macro manually into each existing and new page within the space.

The perfect place for this HTML to live seems to be in the space's page header so it was at the top of every page within the space by default. However, when we insert the HTML into the header, combined with the stylesheet changes, it causes major formatting issues and renders the page unusable. The header becomes large enough that it consumes most of the page and renders the rest of the content unreadable/uneditable. As you can see in the attached screenshot, the regular content is pushed very far down.

The same issue does not happen when inserting the HTML into the page footer, but this is not a viable option as users would have to scroll to the bottom each time they would like to navigate.

Does anyone have any suggestions? We would really love for this HTML to live in the page header without messing up the formatting.

Thank you so much!

Example Header Bug.PNG

1 answer

1 vote
Brian L November 19, 2020

I wanted the same thing, but had lots of challenges getting this done - but did finally figure it out.  Here's what I did:

1.  Create a page to store my navigation bar.  In this page, add an "excerpt macro".  Inside that, add an "html macro".  Inside that html macro, add all your html/css from W3 Schools.

2.  Edit your space, go to look and feel, then navigate to the header section.  Use the following wiki markup language to call an excerpt-include macro of the page you created the nav bar in.  Mine looks like this:

{excerpt-include:NetworkNavBar|nopanel=true}
\\

Note: the double slash is just a carriage return to add spacing, or the "edit" page links overlapped with my nav bar.

Hope this helps you!

Brian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events