手写笔 - 如何实现参数化变换?

时间:2018-01-23 13:59:41

标签: css stylus

我的ul内有N li。我希望将每个li旋转360/N度,以便它们形成一个轮子。

Codepen

我在Stylus中尝试了很多语法来实现这一点,但我总是得到同样的错误:

  

期待" ident"或"字符串",得到"单位360"

例如:

n=8
for i in (1..n)
    li:nth-child({i})
        transform rotate( {360/i}deg ) // expected "ident" or "string", got "unit 360"

n=8
for i in (1..n)
    li:nth-child({i})
        transform rotate( {360/i + 'deg'} ) // expected "ident" or "string", got "unit 360"

n=8
rotation = 0deg
for i in (1..n)
    li:nth-child({i})
        transform rotate( rotation )
    rotation = rotation + {360/i} + "deg" // expected "ident" or "string", got "unit 360"

n=8
rotation = 0deg
for i in (1..n)
    li:nth-child({i})
        transform rotate( rotation )
    rotation += {360/i + "deg"} // expected "ident" or "string", got "unit 360"

有谁知道正确的语法?

1 个答案:

答案 0 :(得分:2)

更容易:

n=8
for i in (1..n)
    li:nth-child({i})
        transform rotate(360/i deg)