如何在调用者文件之外正确调用css文件夹?

时间:2019-06-18 06:46:45

标签: php html css file path

我有这个项目结构:

ProjectName ,其中包含许多子文件夹。其中之一是 includes 文件夹,其中包含 static 文件夹,该文件夹还包含 css 文件夹和 header.php 。现在,我的 header.php 通过在head标签上执行以下操作来调用css文件: <link href="static/css/styles.min.css" rel="stylesheet">,并且这个header.php在我的另一个文件夹中的php文件中被调用。

ProjectName
   includes
      static
         css
            styles.min.css
      header.php
   views
      employee
         departments.php

但是当我在本地主机上运行时。这就是我得到的: GET http://localhost/TeamParrot/views/employee/static/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)

以下是我在做什么的屏幕截图:

Project Folder and deprtments.php 输出量 Output

1 个答案:

答案 0 :(得分:1)

我认为亲戚包括是这里的问题。从包含CSS的角度来看,文件系统认为您在./TeamParrot/views/employee中。

可能与以下内容有关:

<link href="/includes/static/css/styles.min.css" rel="stylesheet"> 

将起作用。包含部分开头的斜杠指示CSS从Webroot加载。