形状不需要额外的元素
可以使用< div> ;:::创建形状
>左边是左边的div,top和bottom的边框.
>右边是由…制成的:之前和它的顶部,右边和底部的边界
>加入两个框的跨度是用以下方式创建的:感谢skewY
工作实例 – 只是形状
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;
}
工作示例 – 带文本
通过上面的例子,内容将不会被包含在整个形状内.相反,它将被限制在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;
}