在CSS3中,有什么区别:
body[data-page~='hello'] {
}
和
body[data-page='hello'] {
}
我已经看到 ~ 被称为一般兄弟组合器,http://css-tricks.com/child-and-sibling-selectors/但在上面的上下文中我不明白。
谢谢。
最佳答案
[att=val]
: Represents an element with theatt
attribute whose value is exactly "val".
[att~=val]
: Represents an element with theatt
attribute whose value is a whitespace-separated list of words, one of which is exactly "val". If "val" contains whitespace, it will never represent anything (since the words are separated by spaces). Also if "val" is the empty string, it will never represent anything.
因此 <body data-page="hello world">
将与第一条规则匹配,但不会与第二条规则匹配。
关于css - CSS3 中的 : body[data-page~ ='hello' ], 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18046264/