我将最喜欢的技术应用于其他形状,但我无法让右侧边框看起来与所需的2px边框成比例。
.tabular_one{
display: inline-block;
position: relative;
width: 500px;
height: 30px;
background: black;
box-sizing: border-box;
-webkit-clip-path: polygon(0 0, 100% 0, 90% 100%, 0 100%);
clip-path: polygon(0 0, 100% 0, 90% 100%, 0 100%);
}
.tabular_one h2{
margin: 0;
position: absolute;
top: 2px;
left: 2px;
width: 496px;
height: 26px;
background-color: #277455;
-webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
clip-path: polygon(0 0, 100% 0, 90% 100%, 0 100%);
}
<div>
<div class="tabular_one">
<h2>TAKE A LOOK AT WHAT WE DO!</h2>
</div>
</div>
链接到codepen中的代码:Example in Code pen
答案 0 :(得分:0)
您可以使用px
而不是%
将内部形状从外部偏移2px,如下所示:
.box{
display: block;
position: relative;
width: 500px;
height: 30px;
background: black;
clip-path: polygon(0 0, 100% 0, 90% 100%, 0 100%);
}
.box h2{
padding:0;
margin: 0;
display: block;
position: absolute;
width: 500px;
height: 30px;
background-color: red;
clip-path: polygon(2px 2px, 493px 2px, 449px 28px, 2px 28px);
}
答案 1 :(得分:0)
这是带有skew
转换和伪元素的另一个想法。您还将比clip-path
获得更好的支持:
h2 {
display: inline-block;
position: relative;
height: 30px;
background: #277455;
border: 2px solid #000;
border-right: none;
box-sizing: border-box;
z-index: 0;
}
h2:before {
content: "";
position: absolute;
z-index: -1;
top: -2px;
bottom: -2px;
left: 100%;
width: 30px;
border: 2px solid #000;
border-left: navajowhite;
background-color: #277455;
transform-origin: top right;
transform: skew(-45deg);
}
<h2>TAKE A LOOK AT WHAT WE DO!</h2>