【问题标题】:Is there any way to "unextend" a class in SASS?有没有办法在 SASS 中“取消扩展”一个类?
【发布时间】:2012-09-12 09:23:56
【问题描述】:

现在我有一个类,我是 @extend-ing 到所有 button 元素。但是,我不想将其扩展到单个按钮,并且不希望通过更改 HTML 来使其成为链接。

有什么方法可以删除 SASS 中特定规则的 @extend

【问题讨论】:

    标签: sass compass-sass


    【解决方案1】:

    没有。您的选择是:

    1. 不要为所有按钮设置样式(使用类或更具体的选择器来避免您的独特元素)
    2. 覆盖唯一元素的样式(取决于所使用的样式,可能很难将按钮返回到每个浏览器的默认外观)

    对您来说最不痛苦的解决方案是使用 :not 选择器:

    // style all buttons, except for ones with the "default" class on them
    button:not(.default) { %extend theStyles }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-25
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多