更改导航栏上的文本颜色

时间:2019-05-18 01:37:29

标签: html css ruby-on-rails

我无法将导航栏的一个元素更改为白色(以匹配其他元素)。我已经在CSS / HTML上尝试过StackOverflow上的其他问题,但是它并没有改变!

这是我的HTML代码:

谢谢

尝试在颜色上进行CSS覆盖,但是没有任何动作。

    <nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #d35400;">
        <a class="navbar-brand" href="">P s y c h l y t X | Scala: Client View</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <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="">Return to Scala application</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/scale">Edit my client's outcomes</a>
                </li>
            </ul>
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-text" >Welcome, <%= @user['info']['name'] %></a>
                </li>
            </ul>
        </div>
    </nav>

4 个答案:

答案 0 :(得分:0)

nav {color: #FFFFFF;}
a:-webkit-any-link {color: #FFFFFF;}
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #d35400;">
        <a class="navbar-brand" href="">P s y c h l y t X | Scala: Client View</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <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="">Return to Scala application</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/scale">Edit my client's outcomes</a>
                </li>
            </ul>
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-text" >Welcome, <%= @user['info']['name'] %></a>
                </li>
            </ul>
        </div>
    </nav>

答案 1 :(得分:0)

这些被归入导航的类是否都具有background-color属性?如果是,请尝试在颜色后面加上!important。

答案 2 :(得分:0)

如果您曾经生成过一个脚手架,则该脚手架将带有其默认的CSS样式,该样式会篡改您的CSS,因此请检查您的asset / stylesheet / scaffold.css并删除其中的CSS代码,看是否有帮助。 / p>

答案 3 :(得分:0)

如果您使用的是Bootstrap:
navbar-dark更改为navbar-whitenavbar-light并添加text-dark

<nav class="navbar navbar-expand-lg navbar-light text-dark" style="background-color: #d35400;">