【问题标题】:Why isn't my CSS file working in my header.php?为什么我的 CSS 文件在 header.php 中不起作用?
【发布时间】:2020-06-19 19:48:38
【问题描述】:

我的 CSS 文件没有加载到我的 header.php 中。我正在使用 CDN 方法来获取引导程序。 我确定我的 href 路径。 感谢您的帮助。

<html lang="en">
<head>
  <title>Demo</title>

  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="stylesheets/style.css">

</head>

<body>

  <div class ="top-bar">
  
    </div>
</body>
</html>

这是我的 style.css 文件

.top-bar{
    width: 100%;
    height: 40px;
    background-color: #2c3e50;
    border-bottom: 2px solid #2c3e50;
}
  

my files structure

【问题讨论】:

  • 你确定style.css 在样式表文件夹中吗?我认为您没有正确引用。 header.php 和样式表文件夹是否在同一目录中?
  • 开始在 chrome 或 firefox 中使用开发者控制台,它会显示是否以及在何处找不到您的 css 文件。非常有用的工具。

标签: javascript html css cdn


【解决方案1】:

您是否尝试在 CSS 路径前添加 /

喜欢: &lt;link rel="stylesheet" type="text/css" href="/stylesheets/style.css"&gt;

【讨论】:

    猜你喜欢
    • 2019-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    • 2021-11-24
    • 1970-01-01
    • 2015-12-07
    • 2012-05-15
    相关资源
    最近更新 更多