无法在引导程序4中更改导航链接的颜色

时间:2020-05-31 23:55:59

标签: html css twitter-bootstrap bootstrap-4

<nav id="section_navbar" class="navbar navbar-expand-lg fixed-top">
        <div class="mx-auto my-2 order-0 order-md-1 position-relative">
            <div id="top_logo" class="container-fluid">
                <span>VirtualQR</span>
            </div>
        </div>
        <div class="navbar-collapse collapse w-100 dual-collapse2 order-2 order-md-1">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-link" href="#section_navbar">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#section_howdoesitwork">How does it work?</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#section_pricing">Pricings</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#section_contact">Contacts</a>
                </li>
            </ul>

我无法通过导航链接更改颜色。我尝试了其他帖子解决方案,但无论如何都无法使它正常工作。 我不知道这是否与我的代码有关。

5 个答案:

答案 0 :(得分:0)

欢迎使用堆栈溢出。这就是您可以做的。

baseURL = "https://api.instagram.com/oauth/access_token"

append = "client_id=\(API.INSTAGRAM_CLIENT_ID)&client_secret=\(API.INSTAGRAM_CLIENTSERCRET)&grant_type=authorization_code&redirect_uri=\(API.INSTAGRAM_REDIRECT_URI)&code=\(code)"

request.httpMethod = "Post"
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField:"Content-Type");
/* Select bootstrap link */

.link{
  color: gray;
}

答案 1 :(得分:0)

使用以下CSS选择器,您将能够更改nav-link类的颜色。

.nav-link {
  color: red;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>



<nav id="section_navbar" class="navbar navbar-expand-lg fixed-top">
  <div class="mx-auto my-2 order-0 order-md-1 position-relative">
    <div id="top_logo" class="container-fluid">
      <span>VirtualQR</span>
    </div>
  </div>
  <div class="navbar-collapse collapse w-100 dual-collapse2 order-2 order-md-1">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a class="nav-link" href="#section_navbar">Home</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#section_howdoesitwork">How does it work?</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#section_pricing">Pricings</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#section_contact">Contacts</a>
      </li>
    </ul>
  </div>
</nav>

答案 2 :(得分:0)

在每个导航链接之后添加内联CSS,如下所示:

<a class="nav-link" href="#section_navbar" style="color: red;">Home</a>

答案 3 :(得分:0)

您可以执行以下操作:

.nav-link{
  color:red;
}

答案 4 :(得分:0)

将此代码放在您的外部CSS文件中

.nav-link {
  color: red;
}

将其作为内部CSS放置,如下所示

<head>
    <style>
           .nav-link {
              color: red;
            }

    </style>
</head>

OR

将其作为内嵌CSS,如下所示

<a class="nav-link" href="#section_navbar" style="color: red;">Home</a>