How to add border to a container with transparent gaps in between

后端 未结 4 1099
自闭症患者
自闭症患者 2020-11-29 07:30

Here is an image of the design which I am trying to achieve with only CSS.

\"enter

4条回答
  •  难免孤独
    2020-11-29 08:14

    I doubt there is a native way to cut borders, so you have to give the illusion that it is a border with more containers.

    Something like this should suffice. Nothing fancy, so browser support won't be an issue either:

    body {
        background: black;
    }
    p {
        color: #ffffff;
        font-size: 16px;
        text-align:center;
        padding:30px;
    }
    .steps-frame-1 {
        position: relative;
        margin-top: 60px;
        width: 50%;
        height: 200px;
        margin-left:auto;
        margin-right:auto;
    }
    .borderColour {
         background-color: #fff;   
    }
    .borderTopLeft {
         position: absolute;
        top:0;
        left: 0;
        width: 10%;
        height:2px;
    }
    .borderTopRight {
        position: absolute;
        top:0;
        right: 0;
        width: 80%;
        height:2px;
    }
    .borderRightTop {
        position: absolute;
        top:0;
        right: 0;
        width: 80%;
        height:2px;
    }
    .borderRightTop {
        position: absolute;
        top:0;
        right: 0;
        width: 2px;
        height: 45%;
    }
    .borderRightBottom {
        position: absolute;
        bottom:0;
        right: 0;
        width: 2px;
        height:45%;
    }
    .borderLeftTop {
        position: absolute;
        top:0;
        left: 0;
        width: 2px;
        height: 45%;
    }
    .borderLeftBottom {
        position: absolute;
        bottom:0;
        left: 0;
        width: 2px;
        height:45%;
    }
    .borderBottom {
        position: absolute;
        bottom:0;
        left: 0;
        width: 100%;
        height:2px;
    }

    content Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.

    http://jsfiddle.net/ddn53xsf/3/

提交回复
热议问题