Often when we do some special shading effect, the way to use the image to do the background is actually very poor, without considering the adaptation of the old version of the browser, we can use the CSS3 to customize the style of the shadow we want.
The following is an example of a curve shadow and an upturned shadow, which explains the process of customizing the shadow.
Look first.
Curve Shadow
Curve shadows can actually be implemented using a double-layer shadow overlay
We will remove the shadow of the picture to do next decomposition should be easier to understand, as follows:
For example, in the shadow of the base of Figure 1, add a shadow with a radian.
1. Figure 1 Base shadow is easy to implement, inner Shadow + outer shadow
. box-shadow1{ box-shadow:0 1px 4px rgba (0,0,0,0.3), 0 0 40px Rgba (0,0,0,0.1) inset;}
2. Then use pseudo-class to add a "fit" shadow after the element, in order to fit, we will use relative positioning, the implementation code is as follows
. box-shadow1{ position:relative; box-shadow:0 1px 4px Rgba (0,0,0,0.3), 0 0 40px Rgba (0,0,0,0.1) inset;}. box-shadow1:after{ content: ""; Position:absolute; background:transparent; top:50%; Setting the width height only the upper and lower left and right margins are set to allow the system to be automatically positioned. bottom:1px; left:10px; right:10px; Z-index:-1; Place the sub-shadow under the primary shadow box-shadow:0 0 20px Rgba (0,0,0,0.7); border-radius:100px/10px;}
This realizes the effect of the curve shadow.
<p class= "box Box-shadow1" > Use Box-shadow1 as a class </p>
The shadow of the upturned edge
In the same vein, an upturned shadow can overlay two parallelogram under the underlying shadow.
Here directly on the decomposition diagram and source code, no longer do the explanation
. box-shadow2{ position:relative; box-shadow:0 1px 4px Rgba (0,0,0,0.3), 0 0 40px Rgba (0,0,0,0.1) inset;}. box-shadow2:before,.box-shadow2:after{ content: ""; Position:absolute; top:20px;bottom:22px; background:transparent; box-shadow:0 8px 20px Rgba (0,0,0,0.7); Z-index:-1; Background: #fff; }.box-shadow2:before{ left:22px; right:12px; Transform:skew ( -12deg) rotate ( -4deg); }.box-shadow2:after{ left:12px; right:22px; Transform:skew (12deg) rotate (4deg); }