浅鱼

子串匹配属性选择器,[key^='starts_with']
今天看到一段css代码:[class*=" icon-"]:before,[class^=ic...
扫描右侧二维码阅读全文
04
2019/01

子串匹配属性选择器,[key^='starts_with']

今天看到一段css代码:

[class*=" icon-"]:before,[class^=icon-]:before

去stackoverflow上面找了下。

这是原话:
[key^='starts_with'] Will look for elements that have the 'key' attribute whose value starts with 'starts_with'. See CSS3 selectors for more details.

也就是说,[key^='starts_with'] 会查找所有key属性的值以'starts_with'开始的元素。
类似的还有:

[key^='starts_with']
[key$='starts_with']
[key*='starts_with']

举例:

[class^='icon-'] - classes starting with 'icon-' (eg. class='icon-blah blah')
[class$='-icon'] - classes ending with '-icon'   (eg. class='blah blah-icon')
[class*='icon']  - classes containing 'icon'     (eg. class='blah xxx-icon-blah')

屏幕快照 2019-01-04 13.35.47.png

参考链接:
1、Odd CSS syntax. [class^='icon-'], [class*=' icon-']

2、CSS 属性选择器详解

Last modification:January 4th, 2019 at 01:37 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment