Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWebsite Owner Tools

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

CSS Shadow Code Generator

When you want a shadow for your content div, or a photo or other image, use the online generator embedded in this article.

The generator was made because I never could remember all the values the CSS box-shadow property can use and in what order it expects them. Every time I looked up the information I thought, "I gotta make a generator for this."

Last week, I reached the tipping point. All the "I gotta's" stacked up in my attention pushed me to finally get it done.

The CSS code the generator creates is for CSS style sheets and also for inline CSS. The definitions can be used in div, img, td, p, pre, and other HTML tags. If the tag contains content, it is almost certainly able to have borders and/or a shadow.

(How?)

In addition to shadows, the generator also creates CSS code for a border, including rounded corners. Example on the right:

(How?)

On the left is the box with a golden shadow reminiscent of a halo.

The CSS Shadow Code Generator makes trying different colors and shadows very, very easy. Type in a value and see the effect immediately. When you're satisfied, copy the CSS code and use it in your own project.

Here are examples of code copied from the CSS Shadow Code Generator being used in img tags:

Will Bontrager
(How?)
Willmaster.com logo
(How?)
Willmaster.com logo
(How?)

Using the CSS Shadow Code Generator

The generator has text boxes and dropdown lists to specify values for the border, rounded corners, and the shadow.

Colors: Colors are specified as any value CSS can use. Generally, I use the color name or the hex value. Examples are "blue" or "#0000ff".

Numbers: Numbers refer to distances or thicknesses. Generally, they are positive values, although the horizontal and vertical shadow values may be negative.

All text fields that aren't for colors are for numbers.

Unless specified otherwise, numbers are assumed to be pixel measurements. As examples, "1" will be treated as "1px" and "1em" will be treated as specified, "1em".

There are three sections with fields for changing the border, corners, and shadow styles.

  1. Border — The section asks for the width, style, and color of the border. For no border, blank the width field.

  2. Corners — The section asks only for the radius of the corners. For no rounded corners, blank the field.

  3. Shadow — The section asks for the horizontal and vertical distance from center to make the shadow. A negative horizontal number means left of center, a positive means right of center. Similarly, a vertical number means above center and otherwise below center. The number 0 is valid for those two fields.

    The section also asks for the shadow's blur, spread, color, and whether or not the shadow is outside the content or inset.

    For no shadow, blank either the horizontal field or the vertical field.

    Tip #1: To make a glow, specify value 0 for both the Horizontal and Vertical fields. Specify a value larger than 0 for the Blur and Spread fields. Then adjust the Blur and Spread values until the blur is what you're looking for.

    Tip #2: To make a shadow instead of a glow, specify values other than 0 for Horizontal, Vertical, and Blur fields. Specify 0 for the Spread field. Then adjust the Horizontal, Vertical, and Blur values until the shadow is what you're looking for.

    Tip #3: Click the "(How?)" link with the examples further above to see how to duplicate the effect in the generator.

The generated CSS code is in a box below the three sections with fields for changing the border, corners, and shadow styles.

The CSS Shadow Code Generator

Below is an area bounded by a dotted gray border. In the middle of the area is a div that will be affected by the values you put into the various fields.

The area bounded by the dotted gray border can be given a different color with the "Ambient color" text field – for those instances when you want to see how the central div looks with different page background colors.

The div in the middle of the area can be given its own background color with the "Background color" text field.

When changing a color, click or tap anywhere outside the field to make the change effective.

Ambient color:
Background color:

Change the values in the Border, Corners, and Shadow text fields until the result is what you're looking for.

To update the div above and the CSS definitions below, click/tap anywhere outside the last updated text field.

Border:

Width:
Style:
Color:

Corners:

Radius:
 

Shadow:

Horizontal:
Vertical:
Blur:
Spread:
Color:
Position:

Border:

Width:
Style:
Color:

Corners:

Radius:

Shadow:

Horizontal:
Vertical:
Blur:
Spread:
Color:
Position:

This box contains the CSS definitions for the values specified in the above fields. Use them in a style sheet or, for inline CSS, in the style attribute of the applicable div, img, or other HTML element.






Using the Generated Code

When satisfied with the effect created by the values you specify, copy the generated CSS code.

Generally, the CSS code would be used as declarations for selectors in a CSS style sheet. It can also be used as inline CSS by pasting the code directly into the HTML element's style attribute. Example:

<div style="border: 1px solid black;
border-radius: 7px;
box-shadow: 0px 0px 3em 1em #999;">
[Content here]
</div>

Remember the URL to this handy generator. Bookmark it. Put it on your Facebook timeline so you'll have it handy. Mention it in a blog post to always have it on hand.

If you know others who would appreciate the generator, certainly let them know.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC