Thank you very much for this one. It’s very helpful…
The new CSS3 properties being adopted by browser manufactures gives us whole new ways to creatively style our websites with out having to resort to images, javascript or flash. As more people start to play with the CSS3 properties you can expect new ways to use them that might not be in ways that you would imagine.
In this case we are going to use the text-shadow property that is currently supported by Firefox, Opera and Safari to create the appearance of inset text. Inset text being text that has been pushed into the background, almost like a reverse embossed effect.
If you look at this image and text treatment you will see what we are trying to achieve. Through color and slight shading it creates the appearance that the text has been pushed inward into the background. Previously we would have had to create this effect in an image, however now we can do it simply by using the text-shadow property (despite its primary use being designed for creating a relief effect).
The first step is to make the text we are working with a darker shade of the the background that it will be sitting on. This will make it look further away to users and shadowed from the light, how dark it should be will depend on the colors you are using. I recommend mocking up your text in photoshop to get the right shade and tone.
To really get the inset 3D effect we need to have a thin line of shading around our text to create the illusion of a ridge. By having it below the text where it normally will be a shadow, it will create the illusion of depth. The color should be lighter shade of the background, but not too much lighter. This is another situation where picking the right color is critical, if it is too light it looks strange and if it is too dark you won't be able to see it. You may want to use photoshop to try mockup up the text in order to pick the right color.
.inset-text {
font-size: 32px;
color: #344251;
text-shadow: 1px 1px 0px #bad3ed;
font-weight: bold;
}
The code is very simple, we are just using the text-shadow property to put a 1 pixel line on the text 1 pixel below it, and 1 pixel to the right.
Here is an example of the result. If a user doesn't have a browser that supports the text-shadow property they still see and can read the text with no issues!
Have some feedback? Leave a commentThank you very much for this one. It’s very helpful…
Thanks nice blog … learned some good tips of css3
Thank you again for this article very useful.
好文章
backing up data- that’s the one thing I often overlook, procrastinate, because it’s always such a tedious task.
蛮好的
Sounds like a good effect, unfortunately I can’t see the effect in my browser. Which versions of browsers currently support CSS3?
Great Tutorial, I really like this look and I’ll take a CSS solution over SIFR
We’re using this on a few of our H tags… I think you’ll see a lot of over-use in 2010 though.
on December 15, 2009
thanks, this is interesting and very usefull