前两对花括号位于一个字符串内,并不标记选择器的末尾.
p[example="public class foo\
{\
private int x;\
\
foo(int x) {\
this.x = x;\
}\
\
}"] { color: red }
Run Code Online (Sandbox Code Playgroud)
如果有人能给我一个在css中使用这样的脚本的例子,这将非常有用.
当然,这是你的榜样:工作小提琴
<p example="public class foo{ private int x; foo(int x) { this.x = x; }}">
test text
</p>
Run Code Online (Sandbox Code Playgroud)
CSS:
p[example="public class foo\
{\
private int x;\
\
foo(int x) {\
this.x = x;\
}\
\
}"] { color: red }
Run Code Online (Sandbox Code Playgroud)
只是不要问我为什么有人会想要使用这个......我相信w3文档的目的是为了表明你可以编写多行属性选择器...