将navbar-brand的颜色更改为两种颜色

时间:2015-08-10 15:13:56

标签: css twitter-bootstrap navbar

我想更改navbar-brand,以便两个单词是两种不同的颜色。我现在无法做到这一点,因为无论我使用什么CSS,它似乎都没有改变颜色。我使用的填充确实生效,所以它是针对它,只是不改变颜色。谁能帮助我做我需要做的事情?

<nav class="navbar navbar-inverse navbar-fluid" role="navigation">
<div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#"><div class="translation">TRANSLATION</div><div class="commons">COMMONS</div></a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav nav pull-right">
            <li>
                <a href="#">Home</a>
            </li>
            <li>
                <a href="#">Register</a>
            </li>
            <li>
                <a href="#">Log In</a>
            </li>
            <li>
                <a href="#">About</a>
            </li>
            <li>
                <a href="#">Contact</a>
            </li>
            <li>
                <a href="#">Donate</a>
            </li>
        </ul>
    </div>
</div>

1 个答案:

答案 0 :(得分:4)

使用.red { color: red; } .white { color: white; }并指定颜色。

&#13;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fluid" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      </button> <a class="navbar-brand" href="#"><span class="red">TRANSLATION</span> <span class="white">Commons</span></a>

    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav nav pull-right">
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Register</a>

        </li>
        <li><a href="#">Log In</a>

        </li>
        <li><a href="#">About</a>

        </li>
        <li><a href="#">Contact</a>

        </li>
        <li><a href="#">Donate</a>

        </li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>
&#13;
any
&#13;
&#13;
&#13;