0426-属性选择器

来源:互联网 发布:php curl 的使用 编辑:程序博客网 时间:2024/05/27 03:29
1.什么是属性选择器?作用: 根据指定的属性名称找到对应的标签, 然后设置属性格式:[attribute]作用:根据指定的属性名称找到对应的标签, 然后设置属性[attribute=value]作用: 找到有指定属性, 并且属性的取值等于value的标签, 然后设置属性最常见的应用场景, 就是用于区分input属性input[type=password]{}<input type="text" name="" id=""><input type="password" name="" id="">-->
1.属性的取值是以什么开头的[attribute|=value] CSS2[attribute^=value] CSS3两者之间的区别:CSS2中的只能找到value开头,并且value是被-和其它内容隔开的CSS3中的只要是以value开头的都可以找到, 无论有没有被-隔开2.属性的取值是以什么结尾的[attribute$=value] CSS33.属性的取值是否包含某个特定的值得[attribute~=value] CSS2[attribute*=value] CSS3两者之间的区别:CSS2中的只能找到独立的单词, 也就是包含value,并且value是被空格隔开的CSS3中的只要包含value就可以找到-->


<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>属性选择器</title>    <style>        /*        p[id]{            color: red;        }        */        p[class=cc]{            color: blue;        }    </style></head><body>
<p id="identity1">我是段落1</p><p id="identity2" class="cc">我是段落2</p><p class="cc">我是段落3</p><p id="identity3" class="para">我是段落4</p><p>我是段落5</p></body></html>
1 0
原创粉丝点击