繁体   English   中英

如何使用自定义的style.css覆盖引导程序?

[英]How can I override bootstrap with my customized style.css?

我试图覆盖一些Bootstraps样式,以创建特定外观。 有人向我解释说,只要在引导CDN之后链接我的自定义style.css,就可以了。

但是,似乎并非如此。

以下是我的index.html:

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Nathan Coder</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

    <nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">

      <a class="navbar-brand" href="index.html" style="margin-left: 100px;">Nathan Coder</a>
    </div>

      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">About</a></li>
        <li><a href="#">|</a></li>
        <li><a href="#">Portfolio</a></li>
        <li><a href="#">|</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

</body>
</html>

这是我的style.css:

nav {
    border-bottom: 3px;
    border-color: #4aaaa5;
}

.navbar-brand {
    color: #4aaaa5;
    background-color: #ffffff;
    font-size: 150%;
    font-family: 'Georgia', Times, Times New Roman, serif;
    padding: 20px;
}

而且它只是无法正常工作。 有什么提示吗?

首先,请确保您在CSS bootsrap之后位于头部。 然后,尝试用body类和preant div类标记它

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style.css">

body.class_name nav {
border-bottom: 3px;
border-color: #4aaaa5;
}
or
div.class_name nav {
border-bottom: 3px;
border-color: #4aaaa5;
}

暂无
暂无

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

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