gpt4 book ai didi

css -::和 ~ 在 css 中做什么?

转载 作者:技术小花猫 更新时间:2023-10-29 10:09:51 24 4
gpt4 key购买 nike

我在推特上看到一个人写的代码,它是这样的:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com