让我们来看看这个简单的css:
tr:nth-child(even) {
background-color: red;
}如何用ScalaTags?编写它
我本想看到一些类似tr.nthChild的东西,但只有firstChild、lastChild和onlyChild。
发布于 2017-03-22 01:06:45
不过,我们可以写自己的:
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"
)
}https://stackoverflow.com/questions/41078777
复制相似问题