CSS3 Box Shadow on Top, Left, and Right Only

前端 未结 10 1556
终归单人心
终归单人心 2020-12-15 03:24

Greetings,

I am trying to apply a CSS3 box shadow to only the top, right, and left of a DIV with a radius that matches the result of the following CSS (minus the bot

相关标签:
10条回答
  • 2020-12-15 03:55

    use the spread value...

    box-shadow has the following values

    box-shadow: x y blur spread color;
    

    so you could use something like..

    box-shadow: 0px -10px 10px -10px black;
    

    UPDATE: i'm adding a jsfiddle

    0 讨论(0)
  • 2020-12-15 03:56

    I fixed such a problem by putting a div down the nav link

     <div [ngClass]="{'nav-div': tab['active']}"></div>
    

    and giving this css to it.

    .nav-div {
        width: inherit;
        position: relative;
        height: 8px;
        background: white;
        top: 4px
      }
    

    and nav link css as

     .nav-link {
        position: relative;
        top: 8px;
    
        &.active {
          box-shadow: rgba(0, 0, 0, 0.3) 0 1px 4px -1px;
        }
      }
    

    Hope this helps!

    0 讨论(0)
  • 2020-12-15 03:57
    #div:before {
     content:"";
     position:absolute;
     width:100%;
     background:#fff;
     height:38px;
     top:1px;
     right:-5px;
    }
    
    0 讨论(0)
  • 2020-12-15 03:58

    I was having the same issue and was searching for a possible idea to solve this.

    I had some CSS already in place for my tabs and this is what worked for me:

    (Note specifically the padding-bottom: 2px; inside #tabs #selected a {. That hides the bottom box-shadow neatly and worked great for me with the following CSS.)

    #tabs {
        margin-top: 1em;
        margin-left: 0.5em;
    }
    #tabs li a {
        padding: 1 1em;
        position: relative;
        top: 1px;
        background: #FFFFFF;
    }
    #tabs #selected {
        /* For the "selected" tab */
        box-shadow: 0 0 3px #666666;
        background: #FFFFFF;
    }
    #tabs #selected a {
        position: relative;
        top: 1px;
        background: #FFFFFF;
        padding-bottom: 2px;
    }
    #tabs ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    #tabs li {
        float: left;
        border: 1px solid;
        border-bottom-width: 0;
        margin: 0 0.5em 0 0;
        border-top-left-radius: 3px;
        border-top-right-radius: 3px;
    }
    

    Thought I'd put this out there as another possible solution for anyone perusing SO for this.

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