文件夹结构
/
|--index.php
+--includes
|--header.html
+--css
|--style.css
我的主项目文件夹中有2个子文件夹。一个是名为“ includes”的文件夹,另一个是“ css”。我index.php
的主文件夹header.html
中有'main/includes'
文件-style.css
我的'main/css'
文件夹中-我的文件夹中
我的index.php包括header.html,如下所示:(include_once('includes/header.html');
这可行!)
我的header.html文件像这样链接CSS :(<link href='../css/style.css' type='text/css' rel='stylesheet'/>
这不起作用!)
我不明白为什么不加载CSS文件。
我不确定使用base标签,但不确定是否使用正确。<base href="http://localhost/main" />
(这不起作用)
您应该尝试使用
<link href='css/style.css' type='text/css' rel='stylesheet'/>
由于index.php
和css
文件夹处于同一级别。
用
<link href='../css/style.css' type='text/css' rel='stylesheet'/>
,
您要求服务器照看style.css
上级目录index.php
不存在的目录。
您还可以使用,/
因为它指向网站的文档根目录。
<link href="/css/style.css" type="text/css" rel="stylesheet" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句