How can I make my navi-bar the same across my html?

后端 未结 9 801
长发绾君心
长发绾君心 2020-12-05 13:26

With each new page I have to update the navigation panel. Which means I go from page to page copying and pasting my navigation bar. The more pages I add the harder it gets.

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 13:42

    If you would like to use PHP to achieve, this, you can do something similar to the code below. You'll have 2 "template" files, and then however many "content" files you need.

    • header.php will include content on the header (logo, nav menu, etc)
    • footer.php will include content on the footer (bottom navigation, copyright, disclaimers, etc.)
    • content.php will include the actual content you wish to display. You can have an infinite number of "content" pages.

    Note that while these files have .php extensions, HTML code still works perfectly fine. So you can do something like this for every content.php:

    content.php

    
    
    
    Your page content will go here

    header.php

    
    
    
    Header content such as nav bar here

    footer.php

    
    
    
    

    In this way, you can change the contents of header.php and footer.php just once, and the changes will be reflected in all the pages you've included the files in.

    If you have any further questions or would like something explained again, feel free to post a comment.

提交回复
热议问题