Something really strange is happening in Safari. I'm doing a simple gradient overlay to do a text fade effect. It works fine in Firefox and Chrome, but not Safari, which I find strange since Safari and Chrome are both Webkit based.
.text-fade {
background: linear-gradient(to top, white, transparent);
bottom: 0;
height: 25%;
margin: 0;
position: absolute;
width: 100%;
}
Safari supports two types of CSS gradients: linear and radial.
To add transparency, we use the rgba() function to define the color stops. The last parameter in the rgba() function can be a value from 0 to 1, and it defines the transparency of the color: 0 indicates full transparency, 1 indicates full color (no transparency).
Instead of:
background: linear-gradient(to top, white, transparent);
Try setting your transparent to an rgba color value. For example:
background: linear-gradient(to top, white, rgba(255,255,255,0));
In other words, the rgb value of both colors should match. For example:
background: linear-gradient(to top, red, rgba(255,0,0,0));
As defined by the w3c spec, transparent is black transparent (rgba(0,0,0,0)). That means that when you are in the middle of the transition, some black should appear.
The color seen in Safari is the correct one, as per the specs.
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