W
W
waltaki2021-07-23 02:37:31
Sass
waltaki, 2021-07-23 02:37:31

How to select selector above in SCSS?

For example, there is this code:

.overlay  {
    position: relative;

    .overlay-layer {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: rgba($black, 1);
        transition: all 0.3s ease;
        opacity: 0;
    }
}
.light-theme * {
    .overlay  {
        .overlay-layer {
            background-color: rgba($black-lt, 1);
        }
    }
}


Is it possible, somehow without creating a full branch for .light-theme *, to do it immediately in the place where you need to change the color? Something like:
.overlay  {
    position: relative;

    .overlay-layer {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: rgba($black, 1);
        transition: all 0.3s ease;
        opacity: 0;

        < .light-theme * {
            background-color: rgba($black-lt, 1);
        }
    }
}


It's just not convenient, for each place to create a new chain of selectors

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-07-23
@waltaki

.overlay  {
    //...
    .overlay-layer {
        //...
        .light-theme * & {
            background-color: rgba($black-lt, 1);
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question