Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to "unextend" a class in SASS?

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?

like image 497
Jason Avatar asked Sep 20 '12 02:09

Jason


People also ask

How do I nest a class in sass?

The first way to nest in SCSS is very simple. Nest a number of HTML elements within a single HTML element. Then in your SCSS simple write the parent selector class name as you would in CSS, then write the nested tags within the parent. Bitchin, you are nesting in SCSS!

What does @extend do in sass?

Sass @extend Directive The @extend directive lets you share a set of CSS properties from one selector to another. The @extend directive is useful if you have almost identically styled elements that only differ in some small details.

How do I alter a class in CSS?

To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class. To do this, start with the element name, then write the period (.)

How do I select multiple classes in SCSS?

SASS/SCSS code to select multiple select classes in the same item. In SCSS, parent selector & symbol is used. This & will be resolved side by side after compilation for CSS.


1 Answers

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 }
like image 159
cimmanon Avatar answered Oct 05 '22 23:10

cimmanon