【发布时间】:2017-01-01 00:00:31
【问题描述】:
我正在尝试实现一个示例 MVC(PHP),其中 CSS 文件似乎不起作用。我怀疑这可能是我的参考风格。 下面的代码是来自视图的标题
Views-> header.php
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" src="public/css/default.css">
</head>
<body >
<div id="header">Header</div>
<div id="content">
<p>dsfds</p>
css 文件 Public/CSS/Default.css
body {
background: silver;
}
为了清晰的图片,这是我的文件夹结构
【问题讨论】:
-
试试../public/css/default.css
-
有一个 htaccess 可能有重写规则,因此 url 可能与您的结构不同。我更喜欢你使用相对的绝对 url。这对你有用。
-
@aman rawat 事实上,最终导致问题的是 .htacess。显然,文件被检测到问题“资源解释为样式表,但使用 MIME 类型文本/html 传输:”必须重写修复问题的 htaccess。
-
在下面的链接stackoverflow.com/questions/22631158/…中找到了这个问题的解决方案pastebin.com/w8UnqFs8