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

后端 未结 13 1116
萌比男神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 18:13

    What I do is create a vertical block for the shadow, and place it next to where my block element should be. The two blocks are then wrapped into another block:

    <div id="wrapper">
        <div id="shadow"></div>  
        <div id="content">CONTENT</div>  
    </div>
    
    <style>
    
    div#wrapper {
      width:200px;
      height:258px;      
    }
    
    div#wrapper > div#shadow {
      display:inline-block;
      width:1px;
      height:100%;
      box-shadow: -3px 0px 5px 0px rgba(0,0,0,0.8)
    }
    
    div#wrapper > div#content {
      display:inline-block;
      height:100%;
      vertical-align:top;
    }
    
    </style>
    

    jsFiddle example here.

    0 讨论(0)
提交回复
热议问题