CSS
HTML
COMPONENTS
CODE HUB
CSS Box Shadow Generator
Configuration
Inset
Color
Horizontal Offset
Vertical Offset
Blur
Spread
Class
Preview
Code
Learn to Code with Lara
Master programming concepts step-by-step with your interactive AI tutor. Lara explains complex logic, reviews your practice exercises, and helps you build a solid foundation in software development.
Interactive coding lessons tailored to your own pace.
Start learning with LaraCSS Box Shadow Generator
In CSS, the box-shadow property is used to create shadow effects for HTML elements. This property allows you to add a shadow to the box (element) on which it's applied, creating depth and separation from the background. The box-shadow property can create a variety of shadow effects by specifying parameters like the shadow's position, size, color, and blur radius.
Here is the basic syntax for the box-shadow property:
box-shadow: h-shadow v-shadow blur spread color;
- h-shadow: This parameter specifies the horizontal position of the shadow. A positive value moves the shadow to the right, and a negative value moves it to the left.
- v-shadow: This parameter specifies the vertical position of the shadow. A positive value moves the shadow downwards, and a negative value moves it upwards.
- blur: This parameter defines the blur radius of the shadow, creating a more or less diffuse shadow effect. Use a value of 0 for a sharp shadow.
- spread: This parameter controls the size of the shadow, expanding or contracting it. A positive value expands the shadow, and a negative value contracts it.
- color: This parameter specifies the color of the shadow.
Here's an example of how to use the box-shadow property to create a simple shadow effect for a box:
.shadow-element {
box-shadow: 10px 10px 5px 0px #888888;
}
In this example:
- The .shadow-element class applies a box shadow.
- 10px specifies a 10-pixel horizontal shadow.
- 10px specifies a 10-pixel vertical shadow.
- 10px sets the blur radius to 5 pixels, creating a slight blur.
- 10px is the spread value (no spread).
- #888888 defines the shadow color as gray.
You can customize the box-shadow property to create a variety of shadow effects, including inset shadows, multiple shadows, and more complex visual effects. It's a versatile property for adding depth and dimension to elements on your web page.