Custom scoop border style - responsive, Custom & dynamic border style - fit in height, Custom border corner - double stroke [closed]

天涯浪子 提交于 2019-12-01 01:48:38

Here's a fiddle ...http://jsfiddle.net/zjw3pg2e/5/ Does this work for you?

body {
    background: #D8D8D8;
}
.corner {
    background:white;
    height:20px;
    width:20px;    
    position:absolute;
}
#sw {
    left: -2px;
    bottom: -2px;
    border-radius: 0px 20px 0px 0px;
    border-top: 2px solid white;
    border-right: 2px solid white;
    background:#D8D8D8;
}
#se {
    right: -2px;
    bottom: -2px;
    border-radius: 20px 0px 0px 0px;
    border-top: 2px solid white;
    border-left: 2px solid white;
    background:#D8D8D8;
}
#nw {
    left: -2px;
    top: -2px;
    border-radius: 0px 0px 20px 0px;
    border-bottom: 2px solid white;
    border-right: 2px solid white; 
    background:#D8D8D8;
}
#ne {
    right: -2px;
    top: -2px;
    border-radius: 0px 0px 0px 20px;
    border-bottom: 2px solid white; 
    border-left: 2px solid white;
    background:#D8D8D8;
}

.box {
    position:relative;
    height:200px;
    width:200px;
    border: solid 2px white;
    background:#D8D8D8;
    border-radius: 5px -5px 5px 5px;
}
.box2 {
    position:relative;
    height:160px;
    width:160px;
    overflow:hidden;
    left: 20px;
    top: 20px;
}
.box2:before{
    content:'';
    position:absolute;
    left:0;
    margin:-20px;
    height:40px;
    width:40px;
    border-radius:100%;
    background:#D8D8D8;
    box-shadow:160px 0 0 #D8D8D8,
    0 160px 0 #D8D8D8,
    160px 160px 0 #D8D8D8,
    0 0 0 500px white;   
}

HTML:

<div class="box">
    <div id="ne"  class="corner"></div> <!--ne, nw, se, sw, are the corners-->
    <div id="nw" class="corner"></div>  <!--of first object-->
    <div id="se" class="corner"></div>
    <div id="sw" class="corner"></div>
    <div class="box2"></div>  <!--box2 is the inner border object-->
</div>

Note that for the encompassing box, ne, nw, se, sw are the inverted corners.

For box2, It is rather difficult to explain what is going on. My suggestion is to play around with the colours of the box-shadow, as well as the pixel positions, to understand how the box-shadow gives the illusion of an inverted border.

Once you get the hang of it, it's really easy to change the dimensions so that it fits your liking.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!