0
讓我們這個簡單的CSS:如何在ScalaTags中編寫tr:nth-child(偶數)?
tr:nth-child(even) {
background-color: red;
}
如何寫在ScalaTags?
我期待看到類似tr.nthChild
,但只有firstChild
,lastChild
和onlyChild
有。
讓我們這個簡單的CSS:如何在ScalaTags中編寫tr:nth-child(偶數)?
tr:nth-child(even) {
background-color: red;
}
如何寫在ScalaTags?
我期待看到類似tr.nthChild
,但只有firstChild
,lastChild
和onlyChild
有。
它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"
)
}