Preventing “double” borders in CSS

后端 未结 17 1527
梦毁少年i
梦毁少年i 2020-12-02 11:49

Say I have two divs next to each other (take https://chrome.google.com/webstore/category/home as reference) with a border.

Is there a way (preferably a CSS trick) to

17条回答
  •  一生所求
    2020-12-02 12:34

    You can use odd selector to achieve this

    .child{
       width:50%;
       float:left;
       box-sizing:border-box;
       text-align:center;
       padding:10px;
       border:1px solid black;
       border-bottom:none;
    }
    .child:nth-child(odd){
       border-right:none;
    }
    .child:nth-last-child(2),
    .child:nth-last-child(2) ~ .child{
       border-bottom:1px solid black
    }
    1
    2
    3
    4
    5
    6
    7
    8

提交回复
热议问题