如何使导航栏跨多个页面保持不变? [英] How to make navbar constant across multiple pages?
问题描述
我查看了之前关于此的问题,人们说 php 并没有找到答案.如何将我的导航栏转换为 php 并在多个 html 页面中使用它.有人能告诉我怎么做吗?我目前正在参加关于 php 的 codecademy 课程,我真的很难理解,所以请耐心等待.
<ul><a href="http://degraphic-design.dunked.com/contact-me" style="text-decoration:none"><li class="contact">联系方式</li></a><li class="dropdown">商店</li><li class="forum">论坛</li><a href="index.html" style="text-decoration:none"><li class="about">关于</li></a><li class="team">团队</li><a href="http://degraphic-design.dunked.com/" style="text-decoration:none"><li class="portfolio">Portfolio</li></a>
假设您的网站根目录中有 about.php
和 home.php
.创建一个名为partials
(或其他)的目录,进入partials
并将导航HTML 的内容放在一个名为nav.php
的文件中.然后在 about.php
和 home.php
中,在要包含导航代码的地方使用它
<?php 包含 'partials/nav.php';?>
I have looked at prevous questions about this and people say php and have not found an answer. how do I convert my navbar to php and use it in multiple html pages. Could someone tell me how to do so? I am currently taking a codecademy course on php and it is really hard for me to understand so please be patient.
<div class="tabs">
<ul>
<a href="http://degraphic-design.dunked.com/contact-me" style="text-decoration:none">
<li class="contact">Contact</li>
</a>
<li class="dropdown">Shop</li>
<li class="forum">Forum</li>
<a href="index.html" style="text-decoration:none">
<li class="about">About</li>
</a>
<li class="team">Team</li>
<a href="http://degraphic-design.dunked.com/" style="text-decoration:none">
<li class="portfolio">Portfolio</li>
</a>
</ul>
</div>
Say you have about.php
and home.php
in the root of your website. Create a directory called partials
(or whatever), go into partials
and put the contents of your navigation HTML in a file called nav.php
. Then in about.php
and home.php
, use this where you want to include the navigation code
<?php include 'partials/nav.php'; ?>
这篇关于如何使导航栏跨多个页面保持不变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!