CSS Shadows
Shadows are important tools for adding depth and dimensionality to web elements. CSS provides two main shadow properties: box-shadow for adding shadows to an element's box, and text-shadow for adding shadows to text content.
box-shadow
The box-shadow property allows you to add one or more shadows to an element. A basic shadow is defined by the following values:
box-shadow: [h-offset] [v-offset] [blur-radius] [spread-radius] [color] [inset];
h-offset(Required): Horizontal offset. A positive value puts the shadow on the right side of the element, a negative value puts it on the left.v-offset(Required): Vertical offset. A positive value puts the shadow below the element, a negative value puts it above.blur-radius(Optional): Blur radius. The higher the number, the more blurred and soft the shadow's edge becomes. 0 means a sharp, unblurred shadow.spread-radius(Optional): Spread radius. A positive value spreads the shadow in all directions, making it larger; a negative value shrinks the shadow. Default is 0.color(Optional): The color of the shadow. If not specified, it usually takes the value of the element'scolorproperty.inset(Optional): If theinsetkeyword is set, the shadow will be an inner shadow, drawn inside the element.
Examples
Multiple Shadows
You can apply multiple shadows to an element by separating them with commas. This can be used to create more complex and realistic depth effects.
text-shadow
The text-shadow property is used to add shadows to text. Its syntax is very similar to box-shadow, but without spread-radius and inset.
text-shadow: [h-offset] [v-offset] [blur-radius] [color];
Examples
By skillfully using shadows, you can significantly improve the texture and professionalism of your design.