使用bootstrap更改导航栏上文本的颜色

时间:2018-04-20 14:34:58

标签: css twitter-bootstrap colors

我正在尝试将导航栏的文字颜色更改为白色。但是,我只能更改右侧文本的颜色(Logout)。 无法更改左侧文字的颜色。

的header.php

<link type="text/css" rel="stylesheet" href="styles//bootstrap.min.css">

        <link type="text/css" rel="stylesheet" href="styles/mediaqueries.css" media="all">
        <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet">    
        <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
          <link rel="stylesheet" href="styles//bootstrap.min_1.css">
        <link rel="stylesheet" href="css/main.css" media="all">
        <link type="text/css" rel="stylesheet" href="styles/mediaqueries.css" media="all">

        <meta http-equiv="content-type" content="text/html; charset=UTF-8">




<div class="mm-page">
            <div class="nav">
                <header id="header" class="full_width clear"> </header>  
                <nav class="navbar navbar-expand-lg navbar-dark navbar-static-top" id="topNav" style="">
                    <a href="index.php" class="navbar-brand"><img src="images/logo.png" alt=" Logo"></a>
                    <div id="container"> 

                        <div class="container-fluid">
                            <div class="collapse navbar-collapse" id="myNavbar">

                            </div>
                            <ul class="nav navbar-nav">
                                <li class="active"</li> <a href="#" class=""><span class=""></span> My Profile</a>
                                <li><a href="#" class=""><span class=""></span> My Portal</a></li>
                                <li><a href="#" class=""><span class=""></span>Contact Us</a></li>
                                <li><a href="#" class=""><span class=""></span>Help</a></li>

                            </ul>
                            <ul class="nav navbar-nav navbar-right">
                                <li><a href="#" class="glyphicon glyphicon-log-out"><span class=""></span> Logout</a></li>
                            </ul>
                        </div>
                    </div>  
                </nav>
            </div>
        </div>

的main.css

.nav.navbar-nav.navbar-right li a {
    color: white;
}

.nav.navbar-nav li a{
    color: white;
}

2 个答案:

答案 0 :(得分:0)

.nav.navbar-nav.navbar-right li a {
    color: white !important;
}

.nav.navbar-nav li a{
    color: white !important;
}

答案 1 :(得分:0)

没有可执行代码就很难测试,但我认为你错过了!important标签。 !important告诉css忽略后续规则。

.nav.navbar-nav.navbar-right li a {
    color: white !important;
}

.nav.navbar-nav li a{
    color: white !important;
}

您可以在此处详细了解css中的!important代码:What does !important in CSS mean?