从上一节展示的CSS3选择器的图表中,我们可以知道,CSS3的属性选择器主要包括以下几种:
E[attr] :只使用属性名,但没有确定任何属性值; E[attr="value"] :指定属性名,并指定了该属性的属性值; E[attr~="value"] :指定属性名,并且具有属性值,此属性值是一个词列表,并且以空格隔开,其中词列表中包含了一个value词,而且等号前面的[〜]不能不写; E[attr^="value"] :指定了属性名,并且有属性值,属性值是以value开头的; E[attr$="value"] :指定了属性名,并且有属性值,而且属性值是以value结束的; E[attr*="value"] :指定了属性名,并且有属性值,而且属值中包含了value; E[attr|="value"] :指定了属性名,并且属性值是value或者以[value-]开头的值(比如说zh-cn);为了更好的说明CSS3属性选择器的使用方法,我们把第一节的demo换成别的结构,如下所示:
div class ="demo clearfix" > a href ="http://www.w3cplus.com" target ="_blank" class ="links item first" id ="first" title ="w3cplus" > 1 a > a href ="" class ="links active item" title ="test website" target ="_blank" lang ="zh" > 2 a > a href ="sites/file/test.html" class ="links item" title ="this is a link" lang ="zh-cn" > 3 a > a href ="sites/file/test.png" class ="links item" target ="_balnk" lang ="zh-tw" > 4 a > a href ="sites/file/image.jpg" class ="links item" title ="zh-cn" > 5 a > a href ="mailto:w3cplus@hotmail" class ="links item" title ="website link" lang ="zh" > 6 a > a href ="" class ="links item" title ="open the website" lang ="cn" > 7 a > a href ="" class ="links item" title ="close the website" lang ="en-zh" > 8 a > a href ="" class ="links item" title ="http://www.sina.com" > 9 a > a href ="" class ="links item last" id ="last" > 10 a > div >
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did101374