How to get css background color on tag to span entire row

前端 未结 8 1465
旧时难觅i
旧时难觅i 2020-12-24 04:53

I have tried everything I can think of in css in order to get a background color to span an entire table row ( tag) But I keep getting a white border around each

相关标签:
8条回答
  • 2020-12-24 05:26

    Removing the borders should make the background color paint without any gaps between the cells. If you look carefully at this jsFiddle, you should see that the light blue color stretches across the row with no white gaps.

    If all else fails, try this:

    table { border-collapse: collapse; }
    
    0 讨论(0)
  • 2020-12-24 05:28

    Try this:

        .rowhighlight > td { background: green;}
    
    0 讨论(0)
  • 2020-12-24 05:35
    tr.rowhighlight td, tr.rowhighlight th{
        background-color:#f0f8ff;
    }
    
    0 讨论(0)
  • 2020-12-24 05:35

    Have you tried setting the spacing to zero?

    /*alternating row*/
    table, tr, td, th {margin:0;border:0;padding:0;spacing:0;}
    tr.rowhighlight {background-color:#f0f8ff;margin:0;border:0;padding:0;spacing:0;}
    
    0 讨论(0)
  • 2020-12-24 05:41
    table{border-collapse:collapse;}
    
    0 讨论(0)
  • 2020-12-24 05:45

    I prefer to use border-spacing as it allows more flexibility. For instance, you could do

    table {
      border-spacing: 0 2px;
    }
    

    Which would only collapse the vertical borders and leave the horizontal ones in tact, which is what it sounds like the OP was actually looking for.

    Note that border-spacing: 0 is not the same as border-collapse: collapse. You will need to use the latter if you want to add your own border to a tr as seen here.

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