Drop Shadow for Text with CSS

My distinguished colleagues at A List Apart already took care of building box-shaped drop shadows. But what if you want the text to have a shadow under every letter? Here are the results of my experiment, which I loathe for two reasons:

  1. You have to repeat the shadowed text when it’s completely unnecessary from a content perspective, and
  2. The div height and font size are hardcoded
But it kind of works.
But it kind of works.

Without further ado, the markup:

<div id='mydiv'>
<div class='shadowed'>The quick brown fox did something or other</div>
<div class='shadow'>The quick brown fox did something or other</div>
</div>

The CSS:

.shadowed {
position: relative;
overflow: hidden;
z-index: 2; }

.shadow {
position: relative;
overflow: hidden;
z-index: 1;
left: 1px; }

#mydiv {
height: 20px;
overflow: hidden;
font-size: 16px;
}

#mydiv .shadow {
color: grey;
top: -19px; }

Does anyone have a less hackish way of doing this? I’d love to hear about it.

This entry was posted in Technology. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>