ProtectedVoid
ProtectedVoid

Reputation: 1315

CSS Selectors - How to apply a defined class on the selector's event

How can I apply a class properties to a class which has selectors in pure CSS? Example:

.one{color:red;}

.two{color:blue;}
.two:hover{ /*Apply class ".one" to class ".two" when the event is triggered */}

Upvotes: 0

Views: 35

Answers (1)

Sonny Prince
Sonny Prince

Reputation: 1152

quite simple:

.two {
    color: blue;
}
.one, .two:hover {
    color: red;
}

Hope this helps! If you ever did port over to SASS you could do it a little cleaner like:

.one {
    color: blue;
}
.two {
    color: red;
    &:hover {
        @extend .one;
    }
}

Upvotes: 2

Related Questions