有什么办法可以“取消扩展”吗?在SASS上课? [英] Is there any way to "unextend" a class in SASS?

查看:45
本文介绍了有什么办法可以“取消扩展”吗?在SASS上课?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Right now I have a class that I'm @extend-ing to all button elements. However, I would like to not extend it to one single button and would prefer not to resort to changing the HTML to make it a link.

有没有删除SASS中特定规则的 @extend 的方法?

Is there any way to remove the @extend for a particular rule in SASS?

推荐答案

否您可以选择以下选项:

No. Your options are:


  1. 不要设置所有按钮的样式(使用类或更具体的选择器来避免使用唯一元素)

  2. 覆盖唯一元素的样式(取决于所使用的样式,很难为每个浏览器将按钮恢复为默认外观)

最痛苦的解决方案是使用:not选择器:

The least painful solution for you would be to use the :not selector:

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

这篇关于有什么办法可以“取消扩展”吗?在SASS上课?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆