CSS学习笔记2——高级选择器

层次选择器

后代选择器

body p{
    
    
    background: red;
}

body后的p标签全部选中

子选择器

body>p{
    
    
    backgorund: yellow;
}

body后一代的p全部选中

弟弟选择器

.ID + p{
    
    
    background: blue;
}

id为ID的标签的下面首个p标签被选中

通用选择器

.ID ~ p{
    
    
    background: green;
}

id为ID的标签的下面所有p标签被选中

属性选择器

选择存在某属性的元素

a[id]{
    
    
    background: orange;
}

选择某属性为某值的元素

a[id="ID"]{
    
    
    background: cyan;
}

选择某属性包含含某值的元素

a[class*="CLASS"]{
    
    
    background: brown;
}

选择某属性以某值开头的元素

a[href^="https"]{
    
    
    background: pink;
}

选择某属性以某值结尾的元素

a[[href$="jpg"]{
    
    
    background: black;
}

所以说这不就是正则吗?

猜你喜欢

转载自blog.csdn.net/jgjfror/article/details/114490379