尽管缺少重写CSS说明符,字体颜色不会改变

问题描述 投票:0回答:1

我最近了解到,如果另一个选择器包含更多特异性,则可以覆盖CSS属性。然而问题是我只是将一个属性(字体颜色)应用到我的页面主体,但它仍然没有注册。

我的问题的基础在于我无法找到我的CSS代码的任何特征,以某种方式覆盖我已应用于正文的字体颜色。这是我的代码:

body {
 background: url(https://images.unsplash.com/photo-1487058792275-0ad4aaf24ca7?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6726719ee78dabe78033950d9f3f7145&auto=format&fit=crop&w=1650&q=80);
 background-size: cover;
 background-position: center;
 font-family: 'Exo';
 color: white;
}

#content {
 text-align: center;
 padding-top: 25%;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Exo" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-lg-12">
      <div id="content">
        <h1>Student Union for Purposeful Education</h1>
        <h3>Learning <em>by</em> students, <em>for</em> students.</h3>
        <hr>
        <button class="btn btn-default btn-lg">Get Started!</button>
      </div>
    </div>
  </div>
</div>

是否有一些说明者覆盖了我没有考虑的白色字体颜色?

html css fonts font-face css-specificity
1个回答
0
投票

您需要使用!important来覆盖bootstrap HTML设置的颜色的默认值

  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="https://fonts.googleapis.com/css?family=Exo" rel="stylesheet"/>
    <div class="container">
      <div class="row">
        <div class="col-lg-12">
          <div id="content">
            <h1>Student Union for Purposeful Education</h1>
            <h3>Learning <em>by</em> students, <em>for</em> students.</h3>
            <hr>
            <button class="btn btn-default btn-lg">Get Started!</button>
          </div>
        </div>
      </div>
    </div>

CSS

 body {
     background: url(https://images.unsplash.com/photo-1487058792275-0ad4aaf24ca7?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6726719ee78dabe78033950d9f3f7145&auto=format&fit=crop&w=1650&q=80);
     background-size: cover;
     background-position: center;
     font-family: 'Exo';
     color: white !important;
    }

    #content {
     text-align: center;
     padding-top: 25%;
    }

这是codepen

https://codepen.io/anon/pen/LQaKzb

© www.soinside.com 2019 - 2024. All rights reserved.