[foo^="bar"] foo属性以bar开头
[foo$="bar"] foo属性以bar结尾
[foo*="bar"] foo属性包含bar
例子:
使用sprite技术整合图片
.icon{background-image:url();width:16px;height:16px;}
.icon-close{background-position:0px 20px;}
<span class="icon icon-close"></span>
使用属性选择器使代码简单:
[class^="icon-"]{background-image:url();width:16px;height:16px;}
.icon-close{background-position:0px 20px;}
<span class="icon-close"></span>
[foo$="bar"] foo属性以bar结尾
[foo*="bar"] foo属性包含bar
例子:
使用sprite技术整合图片
.icon{background-image:url();width:16px;height:16px;}
.icon-close{background-position:0px 20px;}
<span class="icon icon-close"></span>
使用属性选择器使代码简单:
[class^="icon-"]{background-image:url();width:16px;height:16px;}
.icon-close{background-position:0px 20px;}
<span class="icon-close"></span>