Is there any way to “unextend” a class in SASS?

我怕爱的太早我们不能终老 提交于 2019-12-29 08:32:38

问题


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.

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


回答1:


No. Your options are:

  1. Don't style all buttons (use classes or more specific selectors to avoid your unique element)
  2. Override the styles of the unique element (depending on the styles used, it can be very difficult to return a button to its default appearance for every browser)

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 }


来源:https://stackoverflow.com/questions/12505378/is-there-any-way-to-unextend-a-class-in-sass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!