是否可以使用纯 CSS 将连续元素旋转一定量(比如 5 度)。
我尝试了以下方法:
HTML
<div class="container">
<div>Thing 1</div>
<div>Thing 2</div>
<div>Thing 3</div>
</div>
CSS
.container {
counter: my-counter;
}
.container > div {
transform: rotateZ(counter(my-counter)deg);
counter-increment: my-counter 5;
}
/* just to show the counter works: */
.container > div:after {
content: counter(my-counter);
margin-left: 1em;
}
但无济于事。
每个 MDN 的 CSS 计数器:https ://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters