CSS Box Shadow Bottom Only
What is the correct syntax to achieve this effect without affecting other sides? Learn the simple way to create a bottom-only shadow.
If you're looking to apply a shadow only to the bottom of an element in CSS, it's actually pretty straightforward! The box-shadow property gives you full control over the shadow's direction, blur, and spread.
To create a bottom-only shadow, you need to use the right values for horizontal offset, vertical offset, blur, and spread.
Basic Syntax:
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
Breakdown:
- 0 → horizontal offset (no left or right shift)
- 4px → vertical offset (pushes shadow downward)
- 6px → blur radius (softness of the shadow)
- rgba(0, 0, 0, 0.1) → color of the shadow (light black with 10% opacity)
Example in Use:
.bottom-shadow {
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}
Apply this class to any HTML element like a div, card, or button to get a soft shadow only at the bottom.
Tips:
Use inset if you want an inner bottom shadow instead of the usual outer one:
box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.1);
- Play with the values to get a subtle or strong shadow, depending on your design needs.
- This is a clean and efficient way to highlight elements without overwhelming the UI!