📅  最后修改于: 2023-12-03 14:40:16.520000             🧑  作者: Mango
The box-shadow
property in CSS allows you to add shadows to various elements on a webpage. This property accepts several values, including the color of the shadow, its size, blur, and even spread.
The syntax for box-shadow
is as follows:
box-shadow: [horizontal offset] [vertical offset] [blur radius] [spread radius] [color];
Below are some examples of the box-shadow
property in action.
.box {
box-shadow: 2px 2px 5px 1px #ccc;
}
This will create a box with a shadow that is 2px to the right and 2px below the element. The shadow will also have a blur radius of 5px, a spread radius of 1px, and a color of #ccc.
.box {
box-shadow: -2px -2px 5px rgba(0, 0, 0, 0.2),
2px 2px 5px rgba(0, 0, 0, 0.2);
}
This will create a box with a shadow that has two parts. The first part will be on the top and left side, 2px to the left and 2px above the element, with a blur radius of 5px and a color that is 20% black. The second part will be on the bottom and right side, 2px to the right and 2px below the element, with the same blur radius and color.
With the box-shadow
property, you can easily add shadows to various elements on your webpage. By tweaking the values of the property, you can create shadows that are subtle, dramatic, or anything in between.