din*_*o_d 15 html css css3 css-shapes
我想知道这个形状是否可以用尽可能少的html在css3中完成:

到目前为止,我已成功地做到了这一点:
.wrapper {
position: relative;
}
.box {
width: 100px;
height: 100px;
border: 1px solid #000;
position: absolute;
top: 100px;
left: 100px;
}
.box:before {
content: "";
border: 1px solid #000;
border-bottom: 1px solid #fff;
width: 50%;
height: 10px;
position: absolute;
top: -12px;
left: -1px;
}
.box:after {
content: "";
border: 1px solid #000;
border-top: 1px solid #fff;
width: 50%;
height: 10px;
position: absolute;
bottom: -12px;
right: -1px;
}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="box"></div>
</div>Run Code Online (Sandbox Code Playgroud)
小提琴在这里,但我不知道如何扭曲这样,以便我在顶部和底部有直角梯形.
mis*_*Sam 16
可以使用以下命令创建形状<div>:
左侧是div,左边,上边和下边框.
右侧由:before顶部,右侧和底部边框构成
连接这两个盒子的跨度是在:after感谢的基础上创建的skewY
请注意转换属性的浏览器支持.IE 9需要-ms-前缀,Safari和Android浏览器需要-webkit-.

CSS已经压缩,伪元素的边框样式继承自div本身.
div {
border: solid 4px #000;
border-right-width: 0;
width: 100px;
height: 200px;
position: relative;
}
div:before,div:after {
content: '';
display: block;
height: 100%;
width: 100%;
border: inherit;
border-right-width: 4px;
border-left: none;
position: absolute;
left: 100%;
top: 13px;
margin-left: 20px;
}
div:after {
width: 20px;
border-right: none;
top: 5px;
transform: skewY(40deg);
margin: 0;
}Run Code Online (Sandbox Code Playgroud)
<div></div>Run Code Online (Sandbox Code Playgroud)
通过上面的示例,内容不会包含在整个形状中.相反,它将被限制在div半宽内.内容需要以<span>200%的宽度包装,以便在divs约束之外打孔.
div {
border: solid 4px #000;
border-right-width: 0;
width: 100px;
height: 200px;
position: relative;
}
div:before,div:after {
content: '';
display: block;
height: 100%;
width: 100%;
border: inherit;
border-right-width: 4px;
border-left: none;
position: absolute;
left: 100%;
top: 13px;
margin-left: 20px;
}
div:after {
width: 20px;
border-right: none;
top: 5px;
transform: skewY(40deg);
margin: 0;
}
span {
width: 200%;
display: block;
padding: 20px 10px 10px;
}Run Code Online (Sandbox Code Playgroud)
<div><span>This is me writing a large amount of words into the div. I think that you may want a span in order to contain them.</span></div>Run Code Online (Sandbox Code Playgroud)