如何使导航栏跨多个页面保持不变? [英] How to make navbar constant across multiple pages?

查看:47
本文介绍了如何使导航栏跨多个页面保持不变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了之前关于此的问题,人们说 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.phphome.php.创建一个名为partials(或其他)的目录,进入partials 并将导航HTML 的内容放在一个名为nav.php 的文件中.然后在 about.phphome.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆