Preventing “double” borders in CSS

后端 未结 17 1521
梦毁少年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:13

    Using Flexbox it was necessary to add a second child container to properly get the outlines to overlap one another...

    SCSS

    .grid__container {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        margin: 0 1px 0 0; // margin-right 1px to give the correct width to the container
    }
    
    .grid__item {
        flex: 0 1 25%; // grid of 4
        margin: 0 0 1px; // margin-bottom to prevent double lines
    }
    
    .grid__item-outline {
        margin: 0 0 0 1px; // margin-left to prevent double lines
        outline: 1px solid #dedede;
    }
    

提交回复
热议问题