Shadows
CSS Shadow Effects
The CSS shadow properties let add customizable shadow effects to text, images, or even divs.
The shadow properties can take five values:
- Horizontal Offset
positive means the shadow will be to the right.
negative means the shadow will be to the left. - Vertical Offset
positive means the shadow will be below.
negative means the shadow will be above. - Blur Radius (optional)
0 is sharp, and higher numbers are more blurred. - Spread Radius (optional)
positive increases shadow size.
negative decreases shadow size.
0 is default. - Color
Let's try it out!
**If you have a text color on a box and no color set in the shadow, the shadow will take on the text color. But the basic use only requires the horizontal and vertical offsets.
box-shadow: 10px 10px;
You can add color to your specification:
box-shadow: 10px 10px teal;
Let's add a blur!
box-shadow: 5px 5px 5px olive;
We can play with the Spread Radius
box-shadow: 5px 5px 5px 10px navy;
And have no horizontal or vertical offset so the shadow is more like a frame.
box-shadow: 0px 0px 5px 10px olive;
If you use a negative spread radius, you can have a shadow smaller than the object.
box-shadow: 0px 10px 8px -8px black;
You can also create a neat effect with an inner shadow.
box-shadow: inset 0px 0px 15px navy
More Shadows
Text-Shadow
At the very least, you need to specify the horizontal and vertical offsets.
*if you don't specify a shadow color, the color will be the same as the text.
Lorem Ipsum Text
text-shadow: 2px 2px;
Now with a color:
Lorem Ipsum Text
text-shadow: 2px 2px teal;
And then some blur:
Lorem Ipsum Text
text-shadow: 2px 2px 5px teal;
You can use the blur to make it look like the text is glowing:
Lorem Ipsum Text
text-shadow: 0px 0px 5px yellow;
You can also use the shadow like a carving effect if you use a text color the same color as the background.
Lorem Ipsum Text
text-shadow: 2px 2px 3px navy;
You can add multiple shadows to text with a list of shadows separated by commas.
Lorem Ipsum Text
text-shadow: 2px 2px 3px navy, 0px 0px 30px olive, 0px 0px 5px teal;
And you can use the multiple text-shadows to add an outline to letters.
Lorem Ipsum Text
text-shadow: -1px 0px olive, 0px 1px olive, 1px 0px olive, 0px -1px olive;
Even More Shadows
Box-Shadows on Divs
You can combine images, text, and whatever you need into an element that you can put a shadow on to.
box-shadow: 5px 5px 3px 3px teal;
You could even layer text shadowing onto your element that then has a shadow on it.
Shadow Text
text-shadow: 3px 3px 3px navy;
box-shadow: 5px 5px 3px 3px teal;