关系选择器

父元素

子元素

祖先元素

后代元素

兄弟元素

 

让div的子元素变色:

div > span{
    color: salmon;
}
 
后代元素选择器:范围会更大
div span{
    color: seagreen;
}
 
兄弟元素选择器(下一个兄弟元素):
p+span{
    color: seagreen;
}
 
选择下边所有兄弟(兄~弟)
p~span{
    color: seagreen;
}
posted @ 2021-02-13 18:26  俗气小博  阅读(64)  评论(0)    收藏  举报