【问题标题】:CSS file isn't properly linked when I change the .html file to a .php当我将 .html 文件更改为 .php 时,CSS 文件未正确链接
【发布时间】:2016-01-26 03:36:05
【问题描述】:

这个问题是 index.html 文件独有的,正如我之前所说,当它是一个 html 时工作的 CSS 会在扩展​​名更改时停止工作。我检查了两个实例上的 ref 链接,当它是 php 时,CSS 文件最终成为 php 文件本身。我假设它可能由于某种奇怪的原因而无法访问 css?我不确定只有当它是 php 时它是如何转换的。我已经对其他页面做了同样的过程,它工作正常。

如果这意味着什么,部分停止工作的原因是我正在使用的基金会。

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation</title>
<link rel="stylesheet" href="stylesheets/app.css" />
<link rel="stylesheet" href="stylesheets/main.css" />
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.clearing.js"></script>
</head>

我还发现任何 href 链接也停止工作。

【问题讨论】:

  • 请发布链接css文件的代码部分。
  • 网址是否以 localhost 或 file:// 或 c:/ 开头?

标签: php html css zurb-foundation


【解决方案1】:

我猜它是使用错误的 MIME 类型提供的。尝试通过设置如下标题来强制 CSS MIME 类型:

header("Content-type: text/css");

此外,请确保在使用 PHP 时,您应该使用服务器执行。即以下网址是正确的:

http://domain/path/to/index.php
http://localhost/project/index.php

而不是:

file:///c:/wamp/www/project/index.php
file:///c:/myproject/index.php
file:///c:/xampp/htdocs/index.php

【讨论】:

    猜你喜欢
    • 2022-01-25
    • 2022-08-18
    • 1970-01-01
    • 2023-01-02
    • 2016-10-10
    • 2018-08-12
    • 2018-01-05
    • 2020-02-26
    • 1970-01-01
    相关资源
    最近更新 更多