Escape to Parent
Type:
Mixin
@include
escape-to-parent();
* You can call mixins with or without
gls-
namespace (e.g. @include gls-escape-to-parent();
).Escape to Parent Sass mixin allows you to escape to the parent element and use multiple class or id selectors with it. Therefore you can easily control how the selected child element(s) response differently on various cases.
Arguments
Name | Type | Description |
---|---|---|
$selector | string (quoted) | Acceps a value as a |
* Note that you have to use quoted string!
Examples
Call the mixin as many as the number of cases that you want the element response to and pass the related argument for each.
.parent-element{
.element{
@include escape-to-parent(".smartphone"){
background-color: red;
}
@include escape-to-parent(".desktop"){
background-color: green;
}
}
}
//CSS Output
.smartphone.parent-element .element {
background-color: red;
}
.desktop.parent-element .element {
background-color: green;
}