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

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

    My self-made solution which is easy to edit:

    HTML:

    css:

    #shadow-div{
        margin-right:20px; /* Set to 0 if you don't want shadow at the right side */
        margin-left:0px; /* Set to 20px if you want shadow at the left side */
        margin-top:0px; /* Set to 20px if you want shadow at the top side */
        margin-bottom:0px; /* Set to 20px if you want shadow at the bottom side */
        box-shadow: 0px 0px 20px black; 
        height:100px;
        width:100px;
        background: red;
    }
    
    #anti-shadow-div{
        margin:20px;
        display:table;
        overflow:hidden;
    }​
    

    Demo:
    http://jsfiddle.net/jDyQt/103

提交回复
热议问题