【问题标题】:CSS not loading for some reasonCSS由于某种原因没有加载
【发布时间】:2021-12-06 00:13:38
【问题描述】:

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://kit.fontawesome.com/48d7c2e207.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="./css/newsfeed_header.css">
    <link rel="stylesheet" href="./css/newsfeedprofile.css">
    <title>News Feed Profile | My Family Gathering</title>
</head>

当我访问所有网页时,一切都很好。例如本地主机/网站/配置文件。所有的内容都加载了,一切都被设计了。但是当我转到 localhost/website/profile/12345 时,内容加载但没有样式。很奇怪,当我去 localhost/website/profile.php?id=12345 时,一切都正常加载。有人可以引导我走向正确的方向吗?

【问题讨论】:

  • 你能给我看看你的html吗?请问?
  • 听起来你的 CSS 是相对于当前 URL 加载的。查看localhost/website/profile/12345的源码,查看CSS文件的URL
  • @mulquin 网站名称
  • 是的,您的 CSS 似乎是相对加载的,删除 /css 之前的点/句点,它应该可以工作
  • @mulquin 好的,所以你所说的解决了它。我从一开始就删除了 .. 并且它起作用了。感谢大家的帮助!

标签: php css apache


【解决方案1】:

尝试添加类型属性:

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

【讨论】:

  • 路径前的点如果仍然不起作用。
  • 我添加了完整目录 /project/website/css/file.css 并且它以这种方式工作。不过感谢您的帮助!
猜你喜欢
  • 2021-04-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多