-1

I'm adding an 'down' class name to a div using js.

Is it possible in Sass to hit the 'down' class while styling the div

    <div class="insight">
    </div> 

    //add down class with js when clicked
    <div class="insight down">
    </div> 


    .insight{
        background: gray;
        height: 100px;
        width: 100px;

        &:down{
            background: red;
        }
    }
ttmt
  • 5,822
  • 27
  • 106
  • 158

1 Answers1

2

As pointed out in the comments, you've used the wrong selector. In CSS : is a pseudo-element selector, for example span:hover, a:clicked, and so on.

You want an element with two shared classes, so . is fine:

&.down {}

will do exactly what you need. As you've noted & in SASS is the current scoped element so this will compile to

.insight.down

Which is valid CSS and exactly what you want.