Archive

Archive for the ‘1’ Category

12 Fun CSS Text Shadows You Can Copy and Paste

June 7, 2011 Leave a comment

Typography is everyone’s favorite toy in web design. One particularly fun tool that CSS gives you to play with your type is text-shadow, which seems simple enough at first but can be used to create some remarkable effects with a little ingenuity and creativity.

Today we’re going to run through several text-shadow examples that you can copy and paste for your own work.
Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay up on recent content.

The Basic Shadow

The text-shadow property is super easy to work with and works well across allmodern browsers without even so much as a vendor prefix! However, as far as I can tell, IE support, even up through IE9, is zilch. However, using tools likeModernizr will help you pull off advanced CSS3 effects even in silly old IE.

Syntax

The syntax for creating a simple text-shadow is shown below. You have four variables to work with, the first two set your shadow’s position, the third sets the amount of blur and the fourth the color of the shadow.

text-shadow: horizontal-offset vertical-offset blur color;

 

Putting this into action, here’s an example with a shadow that has been moved down two pixels and right four pixels with a three pixel blur and a color of black at 30% opacity.

text-shadow: 2px 4px 3px rgba(0,0,0,0.3);

 

Here’s the result of this code, a nice simple shadow that is quite appealing all by itself.

screenshot

Why rgba?

As a quick note, you don’t have to use rgba for the color of your shadow but can utilize any of the CSS color methods. However, I find that rgba is the ideal color setting for a shadow because it adds yet another dimension to work with. Not only can you set the position, blur and color of the shadow, you can also set its opacity using the alpha value.

This is actually easier than working with other color methods because you might typically have to go hunting for a decent accent to the background color that is perhaps slightly darker or lighter. With rgba you can just use black or white and reduce the opacity to blend it with the background.

Quick and Dirty Letterpress

The great thing about text-shadows is that you can actually do a lot more with them than your average drop shadow. For instance, here’s a quick trick for creating the illusion of inset text.

The first thing you want to do is set your text color to a slightly darker shade than your background color. Next, apply a slight white text-shadow with a reduced opacity.

As you can see, I used a background color of #222 and then set the text to black at 60% opacity. Finally, my white shadow was positioned just slightly down and to the right with a 10% opacity.

body {
    background: #222;
}

#text h1 {
    color: rgba(0,0,0,0.6);
    text-shadow: 2px 2px 3px rgba(255,255,255,0.1);
}

 

screenshot

Hard Shadow

Remember that you don’t have to blur your shadow at all. Due to their retro nature, hard text shadows are actually very “in” right now so feel free to experiment with them in your designs.

text-shadow: 6px 6px 0px rgba(0,0,0,0.2);

 

screenshot

Double Shadow

The real fun begins when you realize that you aren’t restricted to a single shadow. Using a comma to separate the declarations, you can apply as many shadows as you want!

Here’s the basic outline of the syntax. Notice that there’s a comma after the first two shadows and a semicolon after the last shadow.

text-shadow: shadow1, shadow2, shadow3;

 

Putting this into practice, here’s an example with a text treatment that you’ll see all over the web right now. The idea is basically to apply two shadows, the first of which is the same color as your background.

text-shadow: 4px 3px 0px #fff, 9px 8px 0px rgba(0,0,0,0.15);

 

The result is almost a vintage newspaper feel.

screenshot

Down and Distant

Once you start really layering up on the shadows, the results quickly become more and more impressive. It’s really easy to start to create some nice faux 3D effects that your web design savvy users won’t believe is live text.

Below I used a whopping four shadows, all pointed straight down with varying degrees of distance and blur.

    text-shadow: 0px 3px 0px #b2a98f,
                 0px 14px 10px rgba(0,0,0,0.15),
                 0px 24px 2px rgba(0,0,0,0.1),
                 0px 34px 30px rgba(0,0,0,0.1);

 

screenshot

Close and Heavy

Here’s another example of the same idea, this time with three shadows that have been kept much closer to the source. The effect makes your text seem a bit weightier.

text-shadow: 0px 4px 3px rgba(0,0,0,0.4),
             0px 8px 13px rgba(0,0,0,0.1),
             0px 18px 23px rgba(0,0,0,0.1);

 

screenshot

A Little Help

Looking around for what other designers have done I found two excellent techniques that I thought were perfect for this post. The first comes from Mark Dotto and the second from Gordon Hall.

Mark Dotto’s Seriously 3D Text

Here’s one example that I’ve always thought looked really impressive. It comes from MarkDotto.com and utilizes an impressive twelve separate shadows to pull off a very believable 3D effect.

text-shadow: 0 1px 0 #ccc, 
               0 2px 0 #c9c9c9,
               0 3px 0 #bbb,
               0 4px 0 #b9b9b9,
               0 5px 0 #aaa,
               0 6px 1px rgba(0,0,0,.1),
               0 0 5px rgba(0,0,0,.1),
               0 1px 3px rgba(0,0,0,.3),
               0 3px 5px rgba(0,0,0,.2),
               0 5px 10px rgba(0,0,0,.25),
               0 10px 10px rgba(0,0,0,.2),
               0 20px 20px rgba(0,0,0,.15);

 

screenshot

Gordon Hall’s True Inset Text

Notice in the example above I called my technique the “quick and dirty” letterpress effect. That’s because there’s a much more involved way to create some seriously inset text that’s much more believable.

Gordon uses some serious CSS voodoo to pull off not only an outer shadow but a genuine inner shadow as well. Check out his blog post for a full explanation of the technique.

background-color: #666666;
    -webkit-background-clip: text;
    -moz-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: rgba(255,255,255,0.5) 0px 3px 3px;

 

screenshot

More Fun Shadows

Now that you’ve got a good feel for the logic behind the code, here’s a few more examples that I whipped up sans the boring explanations. Feel free to steal them and use them in your work!

Glowing

text-shadow: 0px 0px 6px rgba(255,255,255,0.7);

 

screenshot

Superhero

text-shadow: -10px 10px 0px #00e6e6,
                 -20px 20px 0px #01cccc,
                 -30px 30px 0px #00bdbd;

 

screenshot

Multiple Light Sources

text-shadow: 0px 15px 5px rgba(0,0,0,0.1),
                 10px 20px 5px rgba(0,0,0,0.05),
                 -10px 20px 5px rgba(0,0,0,0.05);

 

screenshot

Soft Emboss

color: rgba(0,0,0,0.6);
text-shadow: 2px 8px 6px rgba(0,0,0,0.2),
                 0px -5px 35px rgba(255,255,255,0.3);

 

screenshot

Conclusion

Like most CSS effects, text-shadows are extremely simple to implement in a basic form but can take on a variety of different forms if you really put some work into them. Using commas as a separator, you can stack CSS shadows on top of each other to dramatically add to the interest and realism of the effect.

Leave a comment below and let us know what you think of the twelve shadows above. Which one is your favorite?

Third Party CSS Apps to Speed Up Your Workflow

June 7, 2011 1 comment

While Dreamweaver CS5.5 is a great program, it’s also quite expensive, so in this article we’re going to look at some third party applications that will allow you to create some cool effects without breaking the bank. Many of these tools are online, which makes life a bit easier.

Ultimate CSS Gradient Generator

CSS1

If you’ve been wanting to create gradients for your layouts, Ultimate CSS Gradient Generatorgives you some really great options. Here’s a rough rundown of the interface. At the top left are a number of presets. These form the basis of some really cool gradients that you can use “out of the box” or custom design your own. Directly below the Presets section is a bar that you can manipulate with the stop markers.

CSS2

Here’s how it works. Simply select a marker and double-click on it to open the color selector to choose your colors. To adjust the position of the stops, you can manually move them along the bar or set the location in percentages. To add a new stop, click between the stop markers. To delete a stop marker, drag it down or select it and click on the delete button in the Stops section.

On the top-right of the interface is a preview of the gradient. Here are some things to note:

* You can set the orientation to vertical or horizontal
* You can set the size
* You can enable the IE checkbox for Internet Explorer

CSS3

Directly below that area is the CSS and at the bottom of this section there are a few subtle, yet important tools. First is the color format. You have the option of using hex, rgb, rgba, hsl, hsla. This last designation, the “a,” is really important. This refers to the image “alpha” or transparency. So if you’re looking at the image code it would read something like this: rgba(41,137,216,1)

The last number, the “1” controls the transparency. “1” is fully opaque. Anything less than that will create varying leves of transparency.

CSS4

The other important feature is: Import from image. When you click on the button it brings up the following dialog box, allowing you to import a gradient image or to use a URL.

And that’s it. You can have a lot of fun with this tool.

CSS Typeset

CSS5

CSS Typeset is a simple tool which allows you to experiment with different types of type, positioning, sizing and more. Once you have what you like, you can copy the CSS code into your layout.

Here’s how it works:

1. Copy some text that you want to test in the Enter Text box on the left.
2. Choose the font that you’d like to use. Your choices are: Courier, Georgia, Palatino, Times New Roman, Arial, Helvetica, Impact, Lucida Sans, Trebuchet MS and Verdana. Note that there’s no need to select the text before choosing the font. Simply changing the font will change the text automatically. For this demo, I’ve chosen to use

* Arial
* Font size 14px
* Font color, Hex 0000FF or RBG: 0,0,255
* Left Justified
* All bolding, italics, etc. off

Next, we’ll look at the controls that govern the spacing between characters, between words and between line.

CSS6

Here’s the text with a figure of five applied. As you can see the spacing between the letters is considerable.

CSS7

In this example, I’ve set the spacing between characters to “1” and the spacing between words to “3.” Note the effect of the spacing.

CSS8

In this sample, I’ve left the spacing between characters at “1”, I’ve set the spacing between words to “0” and Ive set the spacing between lines to “1.5.” Note the effect.

CSS9

And here is our CSS code for that work. As you can see, using this tool can really help you with designing text for your layouts.

CSS Generator

CSS10

 

One of the great things about Dreamweaver is its ability to create customized layouts for building websites, which can save you a lot of time, but what happens if you’re not using Dreamweaver? If you try to create these layouts they can be really time-consuming. Far better to use a template generator if one is available. And that’ where CSS Generator comes into play. Literally within a few minutes you can create a CSS layout that’s ready to use. Not only, but you can also use the HTML5 DOCTYPE.

In this section I’ll input a number of values, just to give you an idea of what the final result will be. Here are my settings:

* DOCTYPE: HTML5
* CSS Reset: * {margin: 0; padding: 0;}
* Layout Width: Fixed
* Width: 960 pixels
* Header: Specify Height enabled 250 pixels
* Sidebars: Two sidebars, one left, one right, 250 pixels spacing for left, 150 pixels for the right
* Footer: Specify height enabled, height 75 pixels.

CSS11

When all of these setting are entered, the blue “Get the Link” button becomes active. Click on it and it brings up the page above, which shows you what your layout will look like. At the top left is a link that states: “Download .zip archive. When you click on it, it downloads two files, a .CSS file and an index file. You now have everything you need to get started with your layouts.

Have fun!