简体   繁体   中英

Conflict between the color in a:link and .nav-link

I use the bootstrap css and the css style sheet by myself. For the following part,

<nav class="navbar navbar-expand-md">  
    <button class="navbar-toggler navbar-dark" type="button" data-toggle="collapse" data-target="#main-navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="main-navigation">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="#Home">Home</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#About">About</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#Contact">Contact</a>
            </li>
        </ul>
    </div>
</nav>

I want "Home, About, Contact" to be black rather than darkred as my other links. So in my css file, I write

a:link, a:visited, a:hover, a:active{
color:darkred;
}
.nav-link {
  color: black;
}

But they turn out to still be darkred. How do I fix this conflict?

I fixed it by changing to

.navbar .nav-link {
  color: black;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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