I often use darken and lighten in SASS styles. I am currently writing a class that will have a border, but will depend on another class for the background color. I want to set the border color of the darken background color of the element.
Something like that:
.blue { background: #00f; } .red { background: #f00; } .border { border: 2px solid darken(background, 20); }
Then the markup will be:
<div id="colored-box" class="blue border"> <p> I have a dark blue border! </p> </div> <div id="colored-box" class="red border"> <p> I have a dark red border! </p> </div>
Naturally, if this worked, since I wrote it here, I would not post it as a question about SO :)
So the question is: Can I base the border color in the background attribute dynamically, and if so, how?
html background-color css sass
asfallows
source share