css属性选择器中[attribute~=value] 和 [attribute*=value]的区别_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:44:09
Original
1423 people have browsed it


[attribute]    用于选取带有指定属性的元素。    [attribute=value]    用于选取带有指定属性和值的元素。    [attribute~=value]    用于选取属性值中包含指定词汇的元素。    [attribute|=value]    用于选取带有以指定值开头的属性值的元素,该值必须是整个单词。    [attribute^=value]    匹配属性值以指定值开头的每个元素。    [attribute$=value]    匹配属性值以指定值结尾的每个元素。    [attribute*=value]    匹配属性值中包含指定值的每个元素。    
Copy after login



下面的例子为包含指定值的 title 属性的所有元素设置样式。适用于由空格分隔的属性值:[title~=hello] { color:red; }下面的例子为带有包含指定值的 lang 属性的所有元素设置样式。适用于由连字符分隔的属性值:[lang|=en] { color:red; }
Copy after login


~=其中的value必须是一个独立的单词,例如 [title~=test] 中 test a可以被选中testa不能被选中.
*=其中的value只要是值的子串就可以,例如test-a,test a和testa均可以被选中.
|=与~=的特性一样,^=与*=的特性一样.因此平时还是用^=和*=较好.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!