我最近了解到,如果另一个选择器包含更多特异性,则可以覆盖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>
&#13;
是否有一些说明符覆盖了我没有考虑的白色字体颜色?
答案 0 :(得分: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