php - CSS 样式未在 XAMPP localhost 中应用

标签 php html css xampp

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

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

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

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

最佳答案

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

假设下面是你的结构

index.php
css
-- main.css

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

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

希望对你有帮助

关于php - CSS 样式未在 XAMPP localhost 中应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41118079/

相关文章:

php - 图像上传上的未识别索引(PHP,Mysql)

javascript - 更改标签颜色

html - 带列表的 Div 背景不起作用

javascript - 根据所选选项更改输入内容

php - Laravel5 Eloquent : How to get a few articles from special condition?

html - 响应式 Div 重新对齐问题

html - Bootstrap 工具提示在初始悬停时处于错误位置,然后处于正确位置

javascript - 从单独的页面访问主页元素 (PageSlide)

php - Laravel Eloquent get where doesn't have, 搜索 wherehas 当不为 null

javascript - 超过 3 向复选框