php - 无法在我的代码中使用 require 或 include 来包含我的 Css 文件

标签 php css

我的网站出现一些不寻常的问题。我已将所有 CSS 文件插入到我的头文件中,并将其包含在每个 php 页面中,下面是一个 php 头文件,我将其包含在每个 php 页面中。然而,标题的内容出现了,但样式根本没有出现。我已经检查了 Css 和包含文件的路径,但我仍然找不到问题。

让我给你下面的路径细节,如果我没有,也许你能发现问题。 header 位于 includes 文件夹中,现在我要做的是从位于 admin 文件夹中的 admincontent.php 调用 header 。

header 中包含的 css 文件:localhost/bobs/css/cssfiles....

Header路径:localhost/bobs/includes/header.php

调用Header的文件:localhost/bobs/admin/admincontent.php

<?php require_once("function.php")?>
<!DOCTYPE html>
<html leng ="en">
<head>
<meta charset="utf-8" /> 
<title>ClickTravelStay</title>
 <link href="css/reset.css" rel="stylesheet" type="text/css">
 <link href="css/general.css" rel="stylesheet" type="text/css">
 <link href="css/footer.css" rel="stylesheet" type="text/css">
 <link href="css/form.css" rel="stylesheet" type="text/css">
 <link href="css/admin.css" rel="stylesheet" type="text/css">
 <link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
 <link href='http://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="topHeader" class="Calign"> 
    <a href ="index.php" id="logoFigure">
    <img src="img/repetimg/logo.png" height="60"/ >
    </a>   
    <div class="cBoth"><!-- clear Both--></div>    
    <ul id="nav">
    <li><a href="index.php">HOME</a></li>
    <li><a href="vication.php">VICATION</a></li>
    <li><a href="carrental.php">CAR RENTAL</a></li>
    <li><a href="#">Corporate</a></li>
    <li><a href="deals.php">DEALS</a></li>
    <li><a href="contact.php">CONTACT</a></li>
    <li><a href="about.php">ABOUT US</a></li>
    </ul>

    <ul id="help">
    <li><a href="#">Book online or call: 080099999 Free from a landline</a></li>
    </ul>
</div><!-- END OF topHeader-->

现在下面的代码就是调用头文件的admincontent.php的代码。

<?php require_once("../includes/header.php");?>
<?php require_once("../includes/connection.php");?>
<?php find_hotel_and_room_forNavig();?>
<div class="cBoth"></div>
<div id="sep"></div>
<div id="content" class="Calign">
<ul id="menu">
             <?php
               Navigation($selected_hot, $selected_rom);
             ?>
             <li><a href="new_hotel.php">+ Add new Hotel >></a></li>
</ul>
<div id="subcontent">
<?php
     echo $selected_hot['hotel_name']."</p>"; 
     echo $selected_rom['room_type']."</p>";
?>
</div><!--end of subcontent-->
</div><!--end of content-->
</body>
</html>

我不明白的是,当我从 index.php 中调用 header 时,表示管理文件夹 像这样(localhost/bobs/index.php)一切正常,但我无法从管理文件夹中引用标题。这是一个错误吗,因为从我看来,路径很好,除非还有其他需要设置的东西。请记住,我可以访问标题的内容,但样式根本不显示。 html 像往常一样出现,但没有任何风格。非常感谢您的支持。

最佳答案

what i don't understand is that when i call the header from the index.php out said the admin folder like this(localhost/bobs/index.php) everything works fine but i cannot refer to the header from the admin folder.

这是按设计工作的:您正在使用 relative paths .请改用 CSS 样式表的绝对路径。

关于php - 无法在我的代码中使用 require 或 include 来包含我的 Css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11643570/

相关文章:

javascript - jquery/JS/css 中的 ning 主页动画?

jquery - 单击图像按钮时工具提示保持可见

javascript - 何时执行动态加载到 head 中的 CSS

javascript - Google table 100 在 10 之前,8 在最后

php - PDO 获取固定行数

php - 如何检查 namespace 中是否存在类?

css - JavaFX,在排序时更改css tablecell

css - 背景图像/颜色在 IE 中不可见

html - 如何删除这些讨厌的额外空间

php - SQL 按公式加权行