How can I add a box-shadow on one side of an element?

后端 未结 13 1164
萌比男神i
萌比男神i 2020-11-28 17:34

I need to create a box-shadow on some block element, but only (for example) on its right side. The way I do it is to wrap the inner element with box-shado

13条回答
  •  广开言路
    2020-11-28 17:54

    Ok, here is one try more. Using pseudo elements and aplying the shadow-box porperty over them.

    html:

    sass:

    .div-to-shadow-1, .div-to-shadow-2
      height: 150px
      width: 150px
      overflow: hidden
      transition: all 0.3s ease-in-out
      &::after
        display: block
        content: ''
        position: relative
        top: 0
        left: 100%
        height: 100%
        width: 10px
        border: 1px solid mediumeagreen
        box-shadow:  0px 7px 12px rgba(0,0,0,0.3)
      &:hover
        border: 1px solid dodgerblue
        overflow: visible
    

    https://codepen.io/alex3o0/pen/PrMyNQ

提交回复
热议问题