首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用ScalaTags编写tr:nth子(偶数)?

如何用ScalaTags编写tr:nth子(偶数)?
EN

Stack Overflow用户
提问于 2016-12-10 18:20:58
回答 1查看 134关注 0票数 0

让我们来看看这个简单的css:

代码语言:javascript
复制
tr:nth-child(even) {
    background-color: red;
}

如何用ScalaTags?编写它

我本想看到一些类似tr.nthChild的东西,但只有firstChildlastChildonlyChild

EN

回答 1

Stack Overflow用户

发布于 2017-03-22 01:06:45

It 看上去不像是ScalaTags提供的

不过,我们可以写自己的:

代码语言:javascript
复制
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"
  )
}

或者如果您不想使用隐式类:

代码语言:javascript
复制
object Foo extends StyleSheet {
  val foo = cls.pseudoExtend(s"nth-child(even)")(
    backgroundColor := "red"
  )
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41078777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档