0

This is a puzzle. The following gradient doesn't display correctly in Safari (works in Firefox and Chrome):

background: linear-gradient(transparent 124px, #de6230);

I have also tried:

background: linear-gradient(rgba(255,0,0,0) 124px, #de6230);

Test it on Safari and you will see the issue: jsFiddle.

How do I fix this?

Henrik Petterson
  • 6,862
  • 20
  • 71
  • 155
  • I can see the issue, very interesting. May be a browser bug? – Gary Woods Feb 20 '17 at 18:52
  • What does actually happens? – Asons Feb 20 '17 at 18:57
  • Second one should work. @LGSon - [Check this out](https://www.w3.org/TR/css3-color/#transparent), it renders as `rgba(0,0,0,0)` which is probably adding some black tinge shade to the gradient/ – Mr. Alien Feb 20 '17 at 18:58
  • @Mr.Alien Agree it should, OP said not, hence my comment ... don't have Safari though so can't do much more – Asons Feb 20 '17 at 19:00
  • 1
    @LGSon The first part of that comment was for OP :) and same here, no Safari, but the place where I work, we have built a cross-browser testing platform online so I tested there :) – Mr. Alien Feb 20 '17 at 19:02
  • Possible duplicate http://stackoverflow.com/questions/30673204/css-linear-gradient-transparency-misbehaving-only-in-safari – Asons Feb 20 '17 at 19:23
  • Another funny possible duplicate http://stackoverflow.com/questions/38391457/linear-gradient-to-transparent-bug-in-latest-safari – Asons Feb 20 '17 at 19:24

2 Answers2

2

Try: background: linear-gradient(rgba(255,255,255,0) 124px, #de6230);

Edit: sorry OP, that still doesn't look the same as your gradient although it is the correct colors, the gray middle just turned to a white middle. The solution I found was:

background: linear-gradient(rgba(222,98,48,0) 124px, #de6230);

222,98,48 is the rgb value of #de6230 so this should work. It's transitioning from your color at 0% alpha to your color at 100% alpha.

0

Try:

background: -webkit-linear-gradient(rgba(255,0,0,0) 124px, #de6230);
background: -moz-linear-gradient(rgba(255,0,0,0) 124px, #de6230);
background: -o-linear-gradient(rgba(255,0,0,0) 124px, #de6230);
background: linear-gradient(rgba(255,0,0,0) 124px, #de6230);

or replace background with background-image

background-image: -webkit-linear-gradient(rgba(255,0,0,0) 124px, #de6230);
background-image: -moz-linear-gradient(rgba(255,0,0,0) 124px, #de6230);
background-image: -o-linear-gradient(rgba(255,0,0,0) 124px, #de6230);
background-image: linear-gradient(rgba(255,0,0,0) 124px, #de6230);

https://www.w3schools.com/Css/css3_gradients.asp

Paweł
  • 75
  • 1
  • 7