I have the following code:
li {
a {
/* style removed for brevity */
&:hover {
color:#4f9269;
@include background-image(linear-gradient(top, #fff, #f0f6f2));
}
}
&.active a {
color:#4f9269;
@include background-image(linear-gradient(top, #fff, #f0f6f2));
}
}
When a menu item is active the active class is applied to the li, so I have had to apply the CSS like this.
I have also consiedered writing a mixin:
@mixin activestate() {
color:#4f9269;
@include background-image(linear-gradient(top, #fff, #f0f6f2));
}
And then doing this:
li {
a {
/* style removed for brevity */
&:hover {
activestate();
}
}
&.active a {
activestate();
}
}
Normally with CSS I would write something like this
li a:hover, li.active a {
/* active styles here */
}
I was wondering if there was a way with SASS to achieve similar output?
SCSS can use the same syntax as the CSS. Moreover, CSS is fully compatible with SCSS. So you can use:
li a:hover, li.active a {
@include activestate();
}
Or in SASS:
li:hover, li.active a
+activestate()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With