尽管缺少覆盖 CSS 说明符,但字体颜色没有改变
Font color not changing despite lack of overriding CSS specifiers
我最近了解到,如果另一个选择器包含更多特异性,则可以覆盖 CSS 属性。然而,问题是我只将 one 属性 字体颜色应用到我的页面正文,但它仍然没有注册。
我的问题的基础在于我找不到我的 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>
是否有一些说明符覆盖了我没有考虑到的白色字体颜色?
您需要使用!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%;
}
这是代码笔
我最近了解到,如果另一个选择器包含更多特异性,则可以覆盖 CSS 属性。然而,问题是我只将 one 属性 字体颜色应用到我的页面正文,但它仍然没有注册。
我的问题的基础在于我找不到我的 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>
是否有一些说明符覆盖了我没有考虑到的白色字体颜色?
您需要使用!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%;
}
这是代码笔