In CSS, there are two types of shadow
// Single Shadow p { text-shadow: 1px 1px 1px #000; } // Multiple Shadow p { text-shadow: 1px 1px 1px #000, 3px 3px 5px blue; }
The first two values specify the length of the shadow offset. The first value specifies the horizontal distance and the second specifies the vertical distance of the shadow. The third value specifies the blur radius and the last value describes the color of the shadow.
Using positive numbers as the first two values ends up with placing the shadow to the right of the text horizontally (first value) and placing the shadow below the text vertically (second value).
The third value, the blur radius, is an optional value which can be specified but don’t have to. It’s the amount of pixels the text is stretched which causes a blur effect. If you don’t use the third value it is treated as if you specified a blur radius of zero.
Creating shadow for text is time consuming unless it's rellay simple shadow. There are thousands of text shadow available online and even generators.
.simple { background: #91877b; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); } .otto { background: #0e8dbc; color: white; 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); } .relief { background-color: #3a50d9; color: #e0eff2; font: italic bold 100px Georgia, Serif; text-shadow: -4px 3px 0 #3a50d9, -14px 7px 0 #0a0e27; } .close { background-color: #fff; color: #202c2d; text-shadow: 0 1px #808d93, -1px 0 #cdd2d5, -1px 2px #808d93, -2px 1px #cdd2d5, -2px 3px #808d93, -3px 2px #cdd2d5, -3px 4px #808d93, -4px 3px #cdd2d5, -4px 5px #808d93, -5px 4px #cdd2d5, -5px 6px #808d93, -6px 5px #cdd2d5, -6px 7px #808d93, -7px 6px #cdd2d5, -7px 8px #808d93, -8px 7px #cdd2d5; } .printers { background-color: #edde9c; color: #bc2e1e; text-shadow: 0 1px 0px #378ab4, 1px 0 0px #5dabcd, 1px 2px 1px #378ab4, 2px 1px 1px #5dabcd, 2px 3px 2px #378ab4, 3px 2px 2px #5dabcd, 3px 4px 2px #378ab4, 4px 3px 3px #5dabcd, 4px 5px 3px #378ab4, 5px 4px 2px #5dabcd, 5px 6px 2px #378ab4, 6px 5px 2px #5dabcd, 6px 7px 1px #378ab4, 7px 6px 1px #5dabcd, 7px 8px 0px #378ab4, 8px 7px 0px #5dabcd; } .glow { color: #444; text-shadow: 1px 0px 1px #ccc, 0px 1px 1px #eee, 2px 1px 1px #ccc, 1px 2px 1px #eee, 3px 2px 1px #ccc, 2px 3px 1px #eee, 4px 3px 1px #ccc, 3px 4px 1px #eee, 5px 4px 1px #ccc, 4px 5px 1px #eee, 6px 5px 1px #ccc, 5px 6px 1px #eee, 7px 6px 1px #ccc; } .vamp { color: #92a5de; background: red; text-shadow:0px 0px 0 rgb(137,156,213),1px 1px 0 rgb(129,148,205), 2px 2px 0 rgb(120,139,196),3px 3px 0 rgb(111,130,187), 4px 4px 0 rgb(103,122,179),5px 5px 0 rgb(94,113,170), 6px 6px 0 rgb(85,104,161),7px 7px 0 rgb(76,95,152), 8px 8px 0 rgb(68,87,144),9px 9px 0 rgb(59,78,135), 10px 10px 0 rgb(50,69,126),11px 11px 0 rgb(42,61,118), 12px 12px 0 rgb(33,52,109), 13px 13px 0 rgb(24,43,100),14px 14px 0 rgb(15,34,91), 15px 15px 0 rgb(7,26,83),16px 16px 0 rgb(-2,17,74), 17px 17px 0 rgb(-11,8,65),18px 18px 0 rgb(-19,0,57),19px 19px 0 rgb(-28,-9,48), 20px 20px 0 rgb(-37,-18,39),21px 21px 20px rgba(0,0,0,1), 21px 21px 1px rgba(0,0,0,0.5),0px 0px 20px rgba(0,0,0,.2); }
Here is the effect -
.shadow{ box-shadow: 3px 3px 5px 6px #ccc; }
box-shadow: [horizontal offset] [vertical offset] [blur radius] [optional spread radius] [color];
The horizontal offset
(required) of the shadow, positive means the shadow will be on the right of the box, a negative offset will put the shadow on the left of the box.The vertical offset
(required) of the shadow, a negative one means the box-shadow will be above the box, a positive one means the shadow will be below the box.The blur radius
(required), if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be, and the further out the shadow will extend. For instance a shadow with 5px of horizontal offset that also has a 5px blur radius will be 10px of total shadow.The spread radius
(optional), positive values increase the size of the shadow, negative values decrease the size. Default is 0 (the shadow is same size as blur).Color
(required) - takes any color value, like hex, named, rgba or hsla. If the color value is omitted, box shadows are drawn in the foreground color (text color). But be aware, older WebKit browsers (pre Chrome 20 and Safari 6) ignore the rule when color is omitted.Inner shadow is same as the outer shadow. Instead it draws the shadow inside the border. Using inset
keyword before the box-shadow value creates inner shadow. Here is an example -
.shadow { -moz-box-shadow: inset 0 0 10px #000000; -webkit-box-shadow: inset 0 0 10px #000000; box-shadow: inset 0 0 10px #000000; }
Using a negative spread radius, you can get squeeze in a box shadow and only push it off one edge of a box.
.one-edge-shadow { box-shadow: 0 8px 6px -6px black; }
These day developer doesn't waste time creating box shadow. There are thousands of example and code available for cool box shadow effects and as well as generators. Here are some-