Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including another class in SCSS

I have this in my SCSS file:

.class-a{   display: inline-block;   //some other properties   &:hover{    color: darken(#FFFFFF, 10%);  }   }  .class-b{   //Inherite class-a here   //some properties } 

In class-b, I would like to inherite all properties and nested declarations of class-a. How is this done? I tried using @include class-a, but that just throws an error when compiling.

like image 265
F21 Avatar asked Mar 05 '12 00:03

F21


People also ask

What is @extend in SCSS?

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 select a class inside a class in CSS?

You can use any CSS selector while nesting with spaces, you can use id selectors with #id-name, tag selectors like h1, pseudo-classes, etc.


1 Answers

Looks like @mixin and @include are not needed for a simple case like this.

One can just do:

.myclass {   font-weight: bold;   font-size: 90px; }  .myotherclass {   @extend .myclass;   color: #000000; } 
like image 151
F21 Avatar answered Sep 25 '22 19:09

F21