Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining . (dot) and & (ampersand) in SASS

Tags:

css

sass

SASS syntax:

.rule{
    &-first.&-second{
        /*rules*/
    }
}

Generates error "Invalid CSS..."

Expected output:

.rule-first.rule-second{
    /*rules*/
}

Can it be done? How?

like image 852
Tauri28 Avatar asked Oct 24 '25 15:10

Tauri28


1 Answers

You can do this with @at-root and interpolation. You will need to be using a version of SASS that supports those features.

.rule {
    @at-root #{&}-first#{&}-second{
        /*rules*/
    }
}

Outputs to:

.rule-first.rule-second {
  /*rules*/
}

Demo: http://sassmeister.com/gist/f7f9e25a0896e47e0adc

like image 66
Steve Sanders Avatar answered Oct 27 '25 04:10

Steve Sanders