[英]Acessing css menu inside root directory
我的根目錄中有 CSS 菜單。我想訪問其他子目錄中的 CSS 菜單。但是當我轉到子目錄時,我無法從子目錄返回,也無法訪問其他子目錄。 在一個子目錄中==> http://localhost/Web/category/category.php當我在“category”文件夾中時,我無法訪問“Web”文件夾中的 CSS 菜單。它提供的文件路徑為http:// localhost/Web/category/item/newform.php.My CSS 菜單在 Web 文件夾中並將其包含在文件中。我該如何解決這個問題?
<ul>
<li class='has-sub' >
<a href='#'><span>Category</span></a>
<ul>
<li class='last'><a href='category/category.php'><span>New Category</span></a></li>
</ul>
</li>
<li class='has-sub'>
<a href='#'><span>Item</span></a>
<ul>
<li class='last'><a href='item/newform.php'><span>Add New Item</span></a></li>
</ul>
</ul>
我不是 100% 理解這里的問題,但聽起來這是一個路徑問題。 嘗試使用完整路徑包含這樣的 css 文件:
<link rel="stylesheet" type="text/css" href="/styles/style.css">
您還可以輸入 css 文件的完整 http 路徑以查看是否有幫助:
<link rel="stylesheet" type="text/css" href="https://www.example.com/styles/style.css">
要從子目錄訪問 CSS 文件夾(位於您的根目錄中),您需要將鏈接包含在位於根目錄下的 php 文件中,例如 header.php。
'header.php'
<link rel="stylesheet" type="text/css" href="/css/style.css">
然后在您的子目錄文件中要求“header.php”
例子:
<?php require_once '../header.php'; ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.