CSS code :
.test {
-webkit-background-clip: text;
color: transparent;
background-image: linear-gradient(to right, #e74c3c 20%, #f4d03f 40%, #2ecc71 60%, #5dade2 80%, #a569bd 100%);
display: inline-block;
}
<span class="test">abcde</span>
but with 'transform',
.test {
-webkit-background-clip: text;
color: transparent;
background-image: linear-gradient(to right, #e74c3c 20%, #f4d03f 40%, #2ecc71 60%, #5dade2 80%, #a569bd 100%);
transform-origin: 0;
transform: scale(1.2); /*any attributes*/
display: inline-block;
}
<span class="test">abcde</span>
It will not work. the result is:
The version of chrome is 69. Can some one tell me why this does not work?
The “background-clip: text” is supported in all main browsers with the Webkit prefix, it allows a background image to be clipped by a text element. In this guide we will look at examples using the background-clip property and the different values you can use.
The background-clip CSS property sets whether an element's background extends underneath its border box, padding box, or content box.
Apparently nested divs were not a problem before for -webkit-background-clip
but in Chrome 69 it doesn't work.
.test {
-webkit-background-clip: text;
color: transparent;
background-image: linear-gradient(to right, #e74c3c 20%, #f4d03f 40%, #2ecc71 60%, #5dade2 80%, #a569bd 100%);
display: inline-block;
}
<span class="test">I'M VISIBLE</span>
<span class="test">
<div>
I'M NOT VISIBLE IN CHROME 69
</div>
</span>
<span class="test">
I'M ALSO NOT VISIBLE IN CHROME 69
<div>
I'M NOT VISIBLE IN CHROME 69
</div>
</span>
The snippet above works fine for all the cases in Firefox (v62) and Chrome Canary(v71)
EDIT Safari (v11) has the same behaviour as chrome 69, just the first case on the snippet works
EDIT 2 If you are using the divs to achieve new lines, replacing the divs with <br/>
is a possible workaround.
.test {
-webkit-background-clip: text;
color: transparent;
background-image: linear-gradient(to right, #e74c3c 20%, #f4d03f 40%, #2ecc71 60%, #5dade2 80%, #a569bd 100%);
display: inline-block;
}
<span class="test">I'M VISIBLE</span>
<span class="test">
<br/>
I'M NOW VISIBLE IN CHROME 69 & Safari (v11)
</span>
<span class="test">
I'M ALSO NOW VISIBLE IN CHROME 69 & Safari (v11)
<br/>
I'M NOW VISIBLE IN CHROME 69 & Safari (v11)
</span>
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