Reputation: 877
Is there any way I can reference parent value, like per example
.btn-blue {
background-color: $light-blue;
&:hover {
background-color: rgba($light-blue,.7);
}
}
.btn-green {
background-color: $light-green;
&:hover {
background-color: rgba($light-green,.7);
}
}
I would like to write one :hover selector which would get the value of the parent. Something like
.btn-blue {
background-color: $light-blue;
}
.btn-green {
background-color: $light-green;
}
.btn-green, .btn-blue {
&:hover {
background-color: rgba($parent_color,.7);
}
}
Any ideas?
Upvotes: 3
Views: 214
Reputation: 16659
You can use mxins and pass the color in:
@mixin btn-color($selColor)
{
background-color: $selColor;
&:hover { background-color: rgba($selColor,.7);
}
}
And use it like so:
.btn-green { @include btn-color($light-green); }
.btn-blue { @include btn-color($light-blue); }
Upvotes: 6