Spacing between thead and tbody

前端 未结 7 1000
情话喂你
情话喂你 2020-12-02 19:23

I have a simple html table like this:


  <         
7条回答
  •  时光取名叫无心
    2020-12-02 20:15

    So box-shadow doesn't work well on the tr element... but it does work on a pseudo content element; sinsedrix put me on the right track and this is what I ended up with:

    table {
        position: relative;
    }
    
    td,th {padding: .5em 1em;}
    
    tr.even td { background-color: yellow; }
    tr.odd td  { background-color: orange; }
    
    thead th:first-child:before {
        content: "-";
    
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: -1;
    
        box-shadow: 0 1px 10px #000000;
        padding: .75em 0;
    
        background-color: #ccc;
        color: #ccc;
    }
    
    thead th {
        padding-bottom: 2em;
    }
    

提交回复
热议问题
Column 1Column 2