简体   繁体   English

为什么我的 CSS 文件在我的 header.php 中不起作用?

[英]Why isn't my CSS file working in my header.php?

My CSS file isn't loading in my header.php.我的 CSS 文件未加载到我的 header.php 中。 I'm using the CDN approach to get bootstrap.我正在使用 CDN 方法来获取引导程序。 I'm sure about my href path.我确定我的 href 路径。 Thanks for helping.感谢您的帮助。

<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>

And this is my style.css file这是我的风格。css 文件

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

my files structure我的文件结构

Did you try prepending / to the CSS path?您是否尝试将/添加到 CSS 路径?

Like: <link rel="stylesheet" type="text/css" href="/stylesheets/style.css">喜欢: <link rel="stylesheet" type="text/css" href="/stylesheets/style.css">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM