3D Text with CSS3
Text shadows are one of the new features quickly becoming popular in CSS3. Mark Dotto has used this technique to create 3D text, which is an incredibly ingenius use for this. His post shows how he did it.
The code which Mark wrote to do this shown here, with a few modifications that I made myself, which I will explain in a moment.
So if you are running Chrome, Firefox, Safari or Opera, the following text should be looking a little less flat than usual.
Hello World
How he accomplishes the 3D effect is to create multiple shadows, which build up to the 3D effect. The order of the parameters in the above code for each line of the text-shadow css tag are [x pos] [y pos] [blur radius] [color]. The first 5 lines create the solid shadow in the 3D effect, by successively creating a shadow. In this example, each successive shadow is moved right and down one pixel from the previous shadow.
The original, by Mark, kept the x value as 0px, which creates a vertical effect as seen on his demo, while the code above shows a slanted effect.
The height of the raised look is determined by how many shadows you draw, so in this example, we have a height of 5, but depending on the effect you want to go for, you can have more or fewer shadows to create relatively higher or lower raised effects. The next several lines draw in a more diffuse shadow around the text. This is not strictly necessary for a 3D effect, but it gives a nice shadowy look to the text. Here, the blurring radius is used, in addition to a semi-transparent color, to create the diffuse shadow.
Like with the main shadow, the effect here can be varied depending on how many of the diffuse shadows, their transparency and blur radii you use. The possibilities are endless.
Originally posted on my old blog, Smoky Cogs on 7 Jan 2011