Extending with Compound Selector in SASS
The use of the @extend directive is not limited to class selectors. In principle, any selector can be extended, even single elements. Let's look at an example:
Let's look at an example:
.active-link {
@extend a:active;
}
a:active {
color: blue;
}
As a result of compilation we will see that .active-link inherits the color property from a:active:
a:active, .active-link {
color: blue;
}
Tell me what the result of compiling the following code will be:
button {
@extend .box:hover;
}
.box:hover {
color: #14147e;
}
Tell me what the result of compiling the following code will be:
button:active {
@extend input:focus;
}
button:blur {
@extend input:blur;
}
input:focus {
color: #14147e;
border-color: #b5b5d1;
}
input:blur {
color: #040433;
background-color: #87878f;
}