【问题标题】:Sass nesting multiple classesSass 嵌套多个类
【发布时间】:2013-08-02 20:32:22
【问题描述】:

好的,这就是我想要实现的目标:

.about{
  /* some styling */
}
.about,.about-pg{
  /* other styling */
}

使用 Sass,我想我可以做到

.about
  /* some styling */
  &,.about-pg
    /* other styling */

但是它编译成:

.about{
  /* some styling */
}
.about,.about .about-pg{
  /* other styling */
}

任何线索为什么以及如何解决这个问题?

【问题讨论】:

  • 是否可以使用变量?
  • @FelipeAls 那会怎样呢?主要问题是 Sass 在我不想要的地方引入了另一个 - 在这种情况下 - '.about'。
  • @cimmanon 他使用了同一段代码,是的。但是,它编译不正确...

标签: css sass


【解决方案1】:

使用@extend:

.about
  /* some styling */
  @extend .about-pg

.about-pg
  /* other styling */

【讨论】:

    猜你喜欢
    • 2017-02-27
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    • 2015-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多