12

On my website, I'm using a text gradient for the heading, but it only works on Chrome and probably Safari (although I haven't tested it), below is the code I'm using for the gradient. I was wondering whether there was a way to achieve the same/similar effect that would work across all 3 browsers?

      background: -webkit-linear-gradient(#eee, #333);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

EDIT: The problem with the other solution that's been posted is that it only works on a white background, as someone said in the comments, which is no good for me as I'm using a grey background.

10
  • 6
    stackoverflow.com/questions/8005447/… Commented Aug 23, 2013 at 12:35
  • stackoverflow.com/questions/8384751/css-text-gradient Apparently it's a webkit thing Commented Aug 23, 2013 at 12:38
  • 1
    IE has a large user base. You should worry about it. Especially as it's perfectly capable of doing CSS gradients (certainly IE10 and later have complete support for the standards, and even older versions can do gradients with just a little bit of effort). Commented Aug 23, 2013 at 12:42
  • 3
    @Spudley it only has a large user-base because people keep supporting it :) Commented Aug 23, 2013 at 12:55
  • 1
    Why wouldn't it work on gray? Commented Aug 23, 2013 at 12:56

2 Answers 2

3

If you want this to work in non-WebKit browsers, you need to use a solution other than CSS.

There are some JavaScript solutions out there, or you can use SVG.

Here's a good blog post on how to do it: http://lea.verou.me/2012/05/text-masking-the-standards-way/

Using JavaScript has the downside of... using JavaScript, but at the end of the day this is only a decorative visual effect.

Sign up to request clarification or add additional context in comments.

1 Comment

SVG was the answer in the end
1

-moz-background-clip:text does not work on firefox, and you won’t be able to achieve clipping effect in Firefox.

You can use cufon for the text gradients, and thay will work on IE, Chrome and Firefox

1 Comment

This changed for Firefox 49+, it is now fully supported by FF and Edge, other browsers still needs prefix though caniuse.com/#feat=mdn-css_properties_background-clip_text

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.