如何影响div的内容

时间:2015-05-05 13:36:36

标签: html css

HTML

<span class = "Box">
<div class = "active">
<a href ="#-night">
<span class ="list">4</span>
<span class="locations"><?php echo $location; ?></span>
<span class="type">Night </span>
</a>        
</div>
</span>

CSS

.Box {
white-space: nowrap;
padding: 0px 20px;
font-size: 110%;
color: blue;}

.list {
height: 30px;
width: 30px;
line-height: 30px;
-moz-border-radius: 15px; /* or 50% */
border-radius: 15px; /* or 50% */
text-align: center;
display: inline-block;
background-color: orange;
color: blue;} 

.locations{
text-transform: uppercase;
color: blue;}

.type {
text-transform: uppercase;
color: blue;}

我希望.active span将.list,.locations和.type的字体颜色更改为深蓝色或任何其他颜色
我不是CSS的专家,在线查看还没有给我任何答案。 如果我发布错误或者提出愚蠢的问题,请道歉。

2 个答案:

答案 0 :(得分:1)

.active .list,
.active .locations,
.active .type {
    color: darkBlue;
}

示例...

&#13;
&#13;
.Box {
white-space: nowrap;
padding: 0px 20px;
font-size: 110%;
color: blue;}

.list {
height: 30px;
width: 30px;
line-height: 30px;
-moz-border-radius: 15px; /* or 50% */
border-radius: 15px; /* or 50% */
text-align: center;
display: inline-block;
background-color: orange;
color: blue;} 

.locations{
text-transform: uppercase;
color: blue;}

.type {
text-transform: uppercase;
color: blue;}

.active .list,
.active .locations,
.active .type {
    color: darkBlue;
}
&#13;
<span class = "Box">
<div class = "active">
<a href ="#-night">
<span class ="list">4</span>
<span class="locations"><?php echo $location; ?></span>
<span class="type">Night </span>
</a>        
</div>
</span>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

添加 - :

a {
    color :red; // your color here
  }

并从其他选择器中删除属性颜色。