Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to differentiate "#id.class" from "#id .class" in SCSS?

How could I, with SCSS, make the difference between :

#id.class {
  color: red;
}

and :

#id .class{
  color: blue
} 

Because I need something like :

#id {
  .class {
    color: red;
  }
  ' ' + .class {
    color: blue;
  }
}
like image 238
Jérémy Pouyet Avatar asked Dec 20 '13 11:12

Jérémy Pouyet


People also ask

What is the formula to differentiate?

Some of the general differentiation formulas are; Power Rule: (d/dx) (xn ) = nxn-1. Derivative of a constant, a: (d/dx) (a) = 0. Derivative of a constant multiplied with function f: (d/dx) (a. f) = af'

How do you differentiate in math?

There are a number of simple rules which can be used to allow us to differentiate many functions easily. If y = some function of x (in other words if y is equal to an expression containing numbers and x's), then the derivative of y (with respect to x) is written dy/dx, pronounced "dee y by dee x" .


2 Answers

You need & to reference to the parent of a selector.

Documentation

#id {
  .class {
    color: red;
  }
  &.class {
    color: blue;
  }
}
like image 143
damian Avatar answered Oct 29 '22 18:10

damian


Use & :

#id {
  .class {
    color: red;
  }
  &.class {
    color: blue;
  }
}
like image 39
Denys Séguret Avatar answered Oct 29 '22 18:10

Denys Séguret