3D Box Shadow effect

前端 未结 6 844
感动是毒
感动是毒 2020-12-06 01:56

So I know how to do a basic box shadow with CSS3. You can see that in the top of the graphic below.

The effect I\'m trying to achieve is a 3D box shadow, as shown in

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 02:43

    You can stack the horizontal/vertical offsets of several box-shadows, each slightly bigger than the previous one. The more shadows you add, the more pronounced the effect. Here is a fiddle example.

    div {
        background: black;
        height: 100px;
        width: 100px;
        box-shadow:  0 01px gray,
                     01px 0 gray,
                     01px 02px gray,
                     02px 01px gray,
                     02px 03px gray,
                     03px 02px gray,
                     03px 04px gray,
                     04px 03px gray,
                     04px 05px gray,
                     05px 04px gray,
                     05px 06px gray,
                     06px 05px gray;
    }
    

提交回复
热议问题