3
I’m trying to do the box-shadow
inherit the shade color in a "dynamic" way, taking the color set in the color
through the currentColor
. So far so good, only the color is "solid", I’m not being able to give it transparency.
Look at this example. The first div is the expected, but the shade color is very strong, I wanted to lighten it using opacity
somehow, but keeping the legacy of currentColor
. I’ve tried so many ways the idea would be something like
box-shadow: 0 4px 8px 0 rgba((--cor), .25);
or even box-shadow: 0 4px 8px 0 rgba(currentColor, .25);
But none of them work, I didn’t want to have to use a pseudo-element like ::after
. And one detail, all the colors of the lib are in hexa
, then I can’t change them to rgb()
:
:root {
--cor: #ff0000;
}
div {
width: max-content;
height: 60px;
margin: 20px;
color: var(--cor);
border: 2px solid currentColor;
box-shadow: 0 5px 5px 0 currentColor;
}
div + div {
--cor: blue;
/* assim tive que coloca a cor em hardcode para funcionar */
box-shadow: 0 5px 5px 0 rgba(0,0,255,0.25);
}
<div>sombra usando o currentColor</div>
<div>queria o currentColor com transparencia</div>
Thanks to the reply friend, but the output of SASS is not what I hope it will not solve the problem, and implement a LIB with JS to solve this much less rss... I ended up solving satisfactorily with the value of
spread-radius
ofbox-shadow
– hugocsl
@hugocsl know it’s late, but can you put an answer as you did? Your question is as a favorite because also want to know :).
– Cmte Cardeal
@Cmtecardeal give me about 10 min that I have put the solution I used, but as I said, it was in the "Brazilian way"...
– hugocsl