user811433
user811433

Reputation: 4149

how to find a css class which has another css class as sibling

I have two css classes A and B that are applied on the same element. I want to change class A only when it has class B as its sibling. Is there any css selector that can do this?

Upvotes: 0

Views: 331

Answers (1)

BoltClock
BoltClock

Reputation: 723428

You can apply styles to different classes as usual:

.A {
    /* Styles for class A */
}

.B {
    /* Styles for class B */
}

Then chain both classes to apply more styles to elements only with both classes:

.A.B {
    /* Styles for elements with both classes A and B only */
}

Upvotes: 3

Related Questions