我在推特上看到一个人写的代码,它是这样的:
div::after {
-webkit-transform: rotate(2deg);
}
div ~ div {
-webkit-transform: rotate(0deg);
}
这是什么?
最佳答案
The double colon replaced the single-colon selectors for pseudo-elements in CSS3 to make an explicit distinction between pseudo-classes and pseudo-elements. For backward compatibility, the single-colon syntax is acceptable for pre-CSS3 selectors. So, :after is a pseudo-class and ::after is a pseudo-element.
The general sibling selector is available in CSS3, and the combinator used in this selector is a tilde character (~).
The selector matches elements that are siblings of a given element. This example will match a p element if it’s a sibling of an h2 element:
http://reference.sitepoint.com/css/generalsiblingselector
http://www.evotech.net/blog/2007/05/after-v-after-what-is-double-colon-notation/
关于css -::和 ~ 在 css 中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10267643/