css - 我无法将外部 css 链接到 HTML

标签 css bootstrap-4

Here is the error now showing in browser console, anyone please explain what is this? 这是html文件的截图

enter image description here

我正在使用 Bootstrap 构建网页,我已将 Bootstrap CSS 和我的 CSS 添加到“head”标签中。这是代码-

 <head>


     <!-- Required meta tags -->
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!--Bootstrap css-->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

      <title>
        first web page using bootstrap
      </title>
<!-- Font awesome for brand name-->
      <link href="https://fonts.googleapis.com/css?family=Permanent+Marker&display=swap" rel="stylesheet"> 

      <!--Our CSS-->
      <link rel="stylesheet" href="CSS\style.css" >

  </head> 

这是我添加到我的 CSS 中的内容-

.mybanner{

  background-color: rgb(12, 8, 5);
  text-align: center;
}


.mybg{

  background-color: rgb(161, 86, 86);
}

.other{
  width: 30px;
 height: 30px;

}

这是完整的代码-

<!DOCTYPE html>
<html lang="en">
  <head>


     <!-- Required meta tags -->
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!--Bootstrap css-->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

      <title>
        first web page using bootstrap
      </title>
<!-- Font awesome for brand name-->
      <link href="https://fonts.googleapis.com/css?family=Permanent+Marker&display=swap" rel="stylesheet"> 

      <!--Our CSS-->
      <link rel="stylesheet" href="CSS\style.css" >

  </head> 
<body>

  <!-- Nav bar-->

  <nav class="navbar navbar-light navbar-expand-lg mybg" style="background-color: #3be79f;">
      <a class="navbar-brand" href="#" style="color: rgb(141, 7, 7); font-size: 25px; font-family: 'Permanent Marker', cursive;"> Stiffy </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Products</a>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Categories
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <a class="dropdown-item" href="#">Beauty</a>
              <a class="dropdown-item" href="#">Health</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="#">Lifestyle</a>
            </div>
          </li>
          <li class="nav-item">
            <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Your Cart</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Sign In</a>
          </li>

        </ul>
        <form class="form-inline my-2 my-lg-0">
          <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
          <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
        </form>
      </div>
    </nav>

    <!--slideshow starts-->


    <div class="fluid-container">

      <div id="myCarousel" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel" data-slide-to="1"></li>
          <li data-target="#myCarousel" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">

          <div class="carousel-item active">
            <img src="../Image\unsplash.jpg"  alt="Los Angeles" style="width:100%;">
            <div class="carousel-caption">
              <h3>Photography</h3>
              <p>It is always so much fun!</p>
            </div>
          </div>

          <div class="carousel-item">
            <img src="../Image\zombie-945622.jpg" alt="Chicago" style="width:100%;">
            <div class="carousel-caption">
              <h3>Ghost</h3>
              <p>Thank you, Mr. Demon</p>
            </div>
          </div>

          <div class="carousel-item">
            <img class="img-1" src="../Image\zombie-979358.jpg" alt="New York" style="width:100%; height: 60%;">
            <div class="carousel-caption">
              <h3> Oops.</h3>
              <p>Ghosts are best.</p>
            </div>
          </div>

        </div>

        <!-- Left and right controls -->
        <a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
          <span class="carousel-control-prev-icon"></span>
        </a>
        <a class="carousel-control-next" href="#myCarousel" data-slide="next">
          <span class="carousel-control-next-icon"></span>
        </a>
      </div>
    </div>


     <!--slideshow ends-->

<!-- Banner starts-->
<div class="fluid-container">
  <div class="row" class="mybanner" style= "background-color: #3be79f;
  text-align: center;"
  >
     <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12"  >

      24*7 Services

     </div>


  <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12"  >

    Cheaper in price

  </div>


<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12"  >

  Deliver ASAP

</div>

</div>

</div>

<!-- Banner ends-->

<!-- other stuff-->
<div class="other">
  <img src="../Image\bride.jpg">
</div>


<!-- JQuery,JS, BOOTSTRAP JS-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

</body>
</html>

我已经正确添加了类,不知道为什么它不起作用。请帮助我。谢谢。

最佳答案

你在html文件夹下,你应该用..走出这个文件夹,然后告诉到哪个文件夹下/CSS/,然后选择文件style.css 使用这个:

<link rel="stylesheet" href="../CSS/style.css" />

关于css - 我无法将外部 css 链接到 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59091337/

相关文章:

html - super 菜单显示不正确

html - 如何使用HTML5+CSS3验证来验证ZK Textbox?

html - 页面加载时如何选择tabindex ="0"从谁开始

html - 为什么 flex 元素不缩小过去的内容大小?

html - .card 类中的列不会相互内联

html - 将左 div 在右 div 的中间垂直对齐

html - 具有两个可折叠左侧导航的三列布局

javascript - 样式引导单选按钮看起来像带有表单验证的普通按钮

还原页面时 Html/CSS 网页内容混合

javascript - 如何使用具有平滑过渡的CSS在其位置垂直翻转图像?