解决方法
插入符(^):选择其中指定属性(rel)的值以特定值(val)开始的元素(
h1[rel^="val"] { /** formatting */ }
h1[rel^="friend"] { color: blue; }
<h1 rel="friend-external-sandwich">I'm Blue.</h1>
<h1 rel="friend2-external-sandwich">I'm Blue.</h1>
<h1 rel="external-sandwich">I'm Black.</h1>
Pipe(|):选择一个元素(< h1>),其中指定属性(rel)的值正好是值(val)或以紧接着 – (val-)
h1[rel|="val"] { /**formatting */ }
h1[rel|="friend"] { color: red; }
<h1 rel="friend-external-sandwich">I'm Red.</h1> <h1 rel="friend2-external-sandwich">I'm Black.</h1>
有关此选择器的更多信息,您可以在这里找到:https://css-tricks.com/attribute-selectors/或官方CSS规范:https://www.w3.org/TR/css3-selectors/#attribute-selectors