How To Make Reuseable HTML Navigation Menus?

前端 未结 10 827
面向向阳花
面向向阳花 2021-01-02 04:41

I\'m sure this topic comes up all the time,
But I can\'t seem to fine a concise answer.

I\'ve got a vertical menu bar that I want to reuse in webpages (>20)

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-02 05:38

    I was searching for a way to write a reusable navigation menu that toggled(show/hide) when clicking a button. I want to share a solution that worked for me in case anyone else is looking to do the same. This solution uses jQuery, html, and css.

    Add this line of code to your head tag in your main index.html file:

    Add div for your nav in body tag:

    
    

    Create a html file that will be where your navigation menu resides. My file is called nav.html and inside the file the contents look like this:

    have you found your one true musubi?` item2 item3

提交回复
热议问题