Dmitry Minkovsky
Dmitry Minkovsky

Reputation: 38183

LESS: Applying a ruleset only when selector is in another selector

Say I've got:

.apple {
    color: red;
}

Now, let's say I've also got:

.big {
    .apple {
        font-size: 1.25em;
    }
}

Is there a way I can put the .big selector inside the rule for .apple? In psuedocode, something like:

.apple {
    color: red;

    &:[WHEN INSIDE `.big`] {
        font-size: 1.25em;
    }
}

Upvotes: 0

Views: 43

Answers (1)

BoltClock
BoltClock

Reputation: 724342

You place the & at the end:

.apple {
    color: red;

    .big & {
        font-size: 1.25em;
    }
}

Upvotes: 4

Related Questions