0

让我们有这个简单的CSS:

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

如何在 ScalaTags 中编写它?

我期待看到类似的东西tr.nthChild,但只有firstChild,lastChildonlyChild

4

1 回答 1

0

看起来不像 ScalaTags 提供它

我们可以自己写:

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"
  )
}
于 2017-03-22T01:06:45.903 回答