Does the CSS direct decendant (>) not have any value in selectivity?

后端 未结 3 1685
北荒
北荒 2020-12-11 02:04

Given the following class declarations and code...



        
3条回答
  •  余生分开走
    2020-12-11 02:54

    You have two conflicting CSS rules. Direct descendant selector has the same specificity as descendant selector if I am not mistaken, therefore the rule parsed later will override the formerly parsed rule, so if your rules are:

    .foo > a { color:green; }
    .bar a { color:red; }
    

    then the color will be red. If your rules are:

    .bar a { color:red; }
    .foo > a { color:green; }
    

    then the color will be green for any anchors which fulfill the selector of both rules.

提交回复
热议问题