【问题标题】:CSS styles not being applied in XAMPP localhostCSS 样式未在 XAMPP localhost 中应用
【发布时间】:2016-12-13 09:54:07
【问题描述】:

我使用 XAMPP 创建 PHP 页面并在本地对其进行测试,但遇到了 CSS 样式未应用的问题。

当我浏览到 http://localhost/example/index.php 时,我得到了正确的 PHP 页面输出,但它没有样式。

当我浏览到 file:///c:/xampp/htdocs/example/index.php 时,我得到了这个页面,它的样式是这样的,所以我知道我的 CSS 链接不是问题。

有人知道发生了什么以及如何解决吗?

【问题讨论】:

  • 显示源代码/输出代码。
  • 显示您的 CSS 链接。
  • 你需要分享css链接的代码

标签: php html css xampp


【解决方案1】:

由于您没有提供任何代码,我怀疑您使用的是绝对路径而不是您应该使用相对路径

假设下面是你的结构

index.php
css
-- main.css

那么你应该像这样链接你的css

<link type="text/css" href="css/main.css" rel="stylesheet" />

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2016-07-18
    • 2020-02-04
    • 2021-10-06
    • 2018-02-04
    • 2016-02-28
    • 2021-09-13
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多