CSS table border spacing inside only

后端 未结 7 618
心在旅途
心在旅途 2021-02-02 05:54

I have trying to work this out for months, and Google hasn\'t helped me. I\'m trying to have spacing between and tags in a table,

7条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 06:04

    Similar to what Steven Vachon said, negative margin may be your best bet.

    Alternatively, you can use calc() to fix the problem.

    CSS:

    /* border-collapse and border-spacing are css equivalents to  */
    
    .boxmp {
        width:100%;
        border-collapse:separate;
        border-spacing:5px 0;
    }
    
    /* border-spacing includes the left of the first cell and the right of the last cell
        negative margin the left/right and add those negative margins to the width
        ios6 requires -webkit-
        android browser doesn't support calc()
        100.57% is the widest that I could get without a horizontal scrollbar at 1920px wide */
    
    .boxdual {
        margin:0 -5px;
        width:100.57%;
        width:-webkit-calc(100% + 10px);
        width:calc(100% + 10px);
    }
    

    Just add whatever margin you take off or the width will be too narrow (100% isn't wide enough).

    提交回复
    热议问题