0

Let's say I have such style definitions:

.a.b   { ... }
.a.b.c { ... }

Is there a way to avoid .a.b part duplication using SASS/SCSS?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
zerkms
  • 249,484
  • 69
  • 436
  • 539

1 Answers1

5

Nest the .a.b.c rule within .a.b and replace the first part with the & combinator:

.a.b {
    ...
    &.c { ... }
}
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • Can you please refer to the documentation? – zerkms Sep 20 '12 at 23:39
  • 1
    @zerkms: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#referencing_parent_selectors_ – Ry- Sep 20 '12 at 23:39
  • 1
    36 seconds... not [my fastest answer](http://stackoverflow.com/questions/5455768/why-do-browsers-think-this-div-tag-isnt-immediately-ended/5455770#5455770) at all :) – BoltClock Sep 20 '12 at 23:41
  • @BoltClock: stackoverflow should have a badge for that - for the answers that have been checked and didn't have modifications after 30 seconds (1 minutes) after question has been posted. – zerkms Sep 20 '12 at 23:43
  • @zerkms: `Bolt Clock` silver badge? – Oleg Sep 20 '12 at 23:51
  • 1
    @o.v.: `zerkms badge` - as long as I proposed to add it ;-P – zerkms Sep 20 '12 at 23:52