Home >CSS >Introduction to CSS >How to make a shadow on one side only

How to make a shadow on one side only

Shadows are easy in CSS with the box-shadow property, but how do you make the shadow appear on one side of an element only?

An example of a shadow on the right of a block:
.test_div
{
  background-color: #FFFFFF;
  width: 100px;
  height: 100px;
  box-shadow: 8px 0 7px -2px #DADADA;
}
/* this puts the shadow on the right of the block */

The values of box-shadow:
1st value = horizontal offset – 8px moves the shadow to the right
2nd value = vertical offset, 0 keeps it level with the element
3rd value = blur radius
4th value (here -2px) = spread – a negative value makes the shadow smaller, so it is not visible at the top and bottom