如果是原生的CSS(不使用编译器)可不可以达到这样的效果? 或者有没有哪个属性或方法是可以使数值与n相关的?
.box:nth-child(n){ -webkit-animation-delay:n s; animation-delay:n s; }
认证高级PHP讲师
On a native basis, some Firefox browsers can implement CSS variables
element { --animation-delay: 3s; } .box:nth-child(n) { -webkit-animation-delay: var(--animation-delay); animation-delay: var(--animation-delay); }
See MDN’s documentation for details https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables
No n in nth-child(n) can be in the form of an b, or odd, even or number, so it should not be used as a variable The effect you want to achieve should be achieved using js Or you can use some css preprocessing language that supports variables
On a native basis, some Firefox browsers can implement CSS variables
See MDN’s documentation for details https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables
No
n in nth-child(n) can be in the form of an b, or odd, even or number, so it should not be used as a variable
The effect you want to achieve should be achieved using js
Or you can use some css preprocessing language that supports variables