gpt4 book ai didi

css - 如何写tr :nth-child(even) in ScalaTags?

转载 作者:太空宇宙 更新时间:2023-11-04 09:26:05 24 4
gpt4 key购买 nike

让我们拥有这个简单的 CSS:

tr:nth-child(even) {
background-color: red;
}

在ScalaTags中怎么写?

我期待看到像 tr.nthChild 这样的东西,但只有 firstChildlastChildonlyChild.

最佳答案

doesn't look like ScalaTags provides it .

不过我们可以自己写:

object Foo extends StyleSheet {

implicit class CreatorWrapper(val creator: Creator) extends AnyVal {
def nthChildEven: Creator = nthChild("even")
def nthChild(arg: String): Creator = creator.pseudoExtend(s"nth-child($arg)")
}

val foo = cls.nthChildEven(
backgroundColor := "red"
)
}

或者如果您不想要隐式类:

object Foo extends StyleSheet {
val foo = cls.pseudoExtend(s"nth-child(even)")(
backgroundColor := "red"
)
}

关于css - 如何写tr :nth-child(even) in ScalaTags?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41078777/

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