我有一个h4标题,当它被选中时,我想改变它的背景颜色。我试过下面的CSS,但它没有奏效。哪里错了?Css将子类添加到h4
.sub_topic h4 {
margin:0 0 0 20px;
color: #fff;
width:120px;
text-align: center;
background-color: #4e7ac7;
border: 3px solid #4e7ac7;
height:20px;
}
.sub_topic h4 .chosen {
background-color: #a0be29;
border: 3px solid #a0be29;
}
我也试过只.chosen
,然后将其添加到<h4>
,但没有奏效。
当你的意思是添加你的意思是h4 + .chosen – theliberalsurfer 2012-01-29 03:58:20