I am trying to achieve a gradient + text shadow effect in Chrome/Safari using CSS text-shadow and a combination of text-shadow and background-image: -webkit-gradient, see example blw. I can only make one of the effects apply(if I add the shadow the gradient disappears. What am I doing wrong?
h1 {
font-size: 100px;
background-image: -webkit-gradient(linear, left top, left bottom, from(white), to(black));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 1px 1px #fff;
}
This answer is similar to the answer by @KennyTM above, except his answer has the shadow hard-coded into the CSS, which is not suitable for dynamic text such as in a CMS. Also, his method requires a separate ID for each instance, which would be very tedious if you plan to use this effect a lot. The example below uses a class instead, and allows dynamic text.
Try this:
And then in your HTML:
Just make sure that the text in the
<div>
matches the text in thetitle
attribute.With some additional formatting (I used Helvetica Neue Ultralight and a dark background), you can get an effect something like this: http://cl.ly/image/2C0k0I3W271D
With no extra HTML markup or pseudo elements you can achieve this effect using the filter property and drop-shadow function. This method also works with a background image vs gradient.
Fiddle: https://jsfiddle.net/eywda89g/
The gradient "disappears" because the
text-shadow
is on a level above the background.We can work around this by copying the text and put it below the original layer, then apply the shadow there, for example: