How to use CSS3 to implement graphic code for curve shading and warping shadows

Source: Internet
Author: User
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); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.