I was curious about currentColor and how it behaves when it is inherited and/or used in other properties. Another aspect is omitting a color value in the border-property for example which should default to the text-color.
.outer {
color: #f90;
border: 5px solid;
box-shadow: 0 0 15px;
text-shadow: 2px 2px 3px;
}
<div class="outer">
Outer Div
</div>
Nothing fancy in the above Snippet.
The shadows and the border is the same Color as the Text.
Now lets inherit the color:
.outer {
color: #f90;
border: 5px solid;
box-shadow: 0 0 15px;
text-shadow: 2px 2px 3px;
}
.inner {
color: lime;
display: inline-block;
border: inherit;
box-shadow: inherit;
}
<div class="outer">
Outer Div
<div class="inner">
Inner Div no CurrentColor
</div>
</div>
Resutls:
In IE11 & Chrome 43 only the Text-Color is lime.
In Firefox 38 on the other hand the shadows are green too. (Note not the border)
When actively setting everything to currentColor the Browsers are showing the same result by displaying only the text in lime and everything else in orange. (As you can see in the final snippet at the bottom)
/**
* playing with currentColor
*/
body {background: darkgray;} /* friendly wink */
.outer {
width: 85%;
color: #f90;
border: 5px solid;
box-shadow: 0 0 15px;
text-shadow: 2px 2px 3px;
padding: 15px; margin: 15px;
}
.outer.currentColor {
border: 5px solid;
box-shadow: 0 0 15px currentColor;
text-shadow: 2px 2px 3px currentColor;
}
.inner {
color: lime;
display: inline-block;
border: inherit;
box-shadow: inherit;
}
.inner.resetting {
border-color: currentColor;
/* text-shadow-color: currentColor; /* does not exist */
/* box-shadow-color: currentColor; /* does not exist */
}
<div class="outer">
Outer Div
<div class="inner">
Inner Div no CurrentColor
</div>
</div>
<div class="outer currentColor">
Outer Div
<div class="inner">
Inner Div with CurrentColor
</div>
<div class="inner resetting">
Inner Div with CurrentColor
</div>
</div>
Questions:
- Why is there a difference with the border in Firefox when omitting currentColor
- Why does inherit not use the color value on the same element?
- Is there a way to use the same properties and switching the color? (for border-color there is as you can see in the example by resetting it)
Here is also a dabblet link if you want to play around with it:
http://dabblet.com/gist/587ea745c7cda7a906ee