【问题标题】:Custom scoop border style - responsive, Custom & dynamic border style - fit in height, Custom border corner - double stroke [closed]自定义勺形边框样式 - 响应式,自定义和动态边框样式 - 适合高度,自定义边框角 - 双笔画[关闭]
【发布时间】:2015-02-27 19:04:11
【问题描述】:

有没有办法在 CSS 或 jQuery 中制作自定义勺形边框样式?

如下图:

【问题讨论】:

标签: jquery html css css-shapes


【解决方案1】:

这是一个小提琴...http://jsfiddle.net/zjw3pg2e/5/ 这对你有用吗?

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>

请注意,对于包围盒,nenwsesw 是倒角。

对于box2,很难解释发生了什么。我的建议是尝试使用 box-shadow 的颜色以及像素位置,以了解 box-shadow 如何产生倒置边框的错觉。

一旦掌握了窍门,就可以很容易地更改尺寸以符合自己的喜好。

【讨论】:

  • 您好 Bolboa,您的想法也不错,但添加内容似乎很困难。但最后我让它工作了 - 这是细节 - github.com/atiar-cse/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-18
  • 2016-02-09
  • 1970-01-01
相关资源
最近更新 更多