在这种情况下,css的级联部分似乎不适用。我肯定我做了很明显的错事。如果您使用类/元素选择器组合(.core-services li),那么它是否以某种方式使it凌驾于试图覆盖它的未来行之上?(媒体查询声明被“忽略”)。唯一起作用的是!重要的,如果可能的话,我想避免。
html:
<section class="core-services">
<div class="site-wrap">
<ul>
<li class="green_1">
<i class="fa fa-database"></i>
<p>Efficiently unleash cross-media information without cross-media value.</p>
</li>
<li class="green_2">
<i class="fa fa-code"></i>
<p>Efficiently unleash cross-media information without cross-media value.</p>
</li>
<li class="green_3">
<i class="fa fa-rocket"></i>
<p>Efficiently unleash cross-media information without cross-media value.</p>
</li>
<li class="green_4">
<i class="fa fa-terminal"></i>
<p>Efficiently unleash cross-media information without cross-media value.</p>
</li>
</ul>
</div>
</section>css:
.core-services {
background-color: #00873B;
overflow: hidden;
}
.core-services ul {
margin: 0;
padding: 0;
}
.core-services li {
display: inline-block;
float: left;
width: 280px;
border-radius: 5px;
margin: 0 10px;
text-align: center;
padding: 35px 45px;
background-color: rgba(255,255,255,0.6);
box-shadow: 0px 0px 15px rgba(0,0,0,0.4);
}
@media screen and (max-width: 1240px) {
.green_4 {
margin-top: 1.7%;
}
}
.core-services i {
font-size: 80px;
color: rgb(57, 55, 57);
margin-bottom: 35px;
}jsbin:http://jsbin.com/lugacazine/3/edit?html,css,output
发布于 2015-02-17 22:35:09
.green_4的特异性为0010,而..core services li的特异性为0011。为了提高.green_4的特异性,添加它的父选择器如下:
@media screen and (max-width: 1240px) {
.core-services .green_4 {
margin-top: 1.7%;
}}
到这里阅读有关CSS特性的更多信息:http://www.w3.org/TR/css3-selectors/#specificity
https://stackoverflow.com/questions/28572371
复制相似问题