3D Box Shadow effect

前端 未结 6 840
感动是毒
感动是毒 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:41

    Here's a little implementation, inspired by @Vitorino fernandes, in stylus...

    offset = 10
    border = 3
    .offsetbox
       margin offset
       padding offset
       text-align center
       box-shadow inset 0 0 0 unit(border,px) black
       background white
       display inline-block
       position relative
       &:after,
       &:before
          content ''
          background black
          position absolute
       &:after
          width 100%
          height offset
          transform translatey(100%) skewx(-45deg)
          right (offset/2)
          bottom 0
       &:before
          height 100%
          width offset
          transform: translatex(-100%) skewy(-45deg)
          left 0
          top (offset/2)
    

提交回复
热议问题