我想在html中创建一个具有截止角并且形状周围有边框的形状。
我可以制作没有边框的截断形状:
HTML:
<div class="cut-off"></div>
的CSS:
.cut-off{
position:relative;
top:400px;
left:400px;
height:155px;
width:200px;
background:red;
}
.cut-off:after{
position:absolute;
bottom:0px; right:-20px;
content:".";
text-indent:-999px; overflow:hidden;
display:block;
width:0px; height:0px;
border-top: 20px solid green;
border-right: 20px solid transparent;
}
.cut-off:before{
position:absolute;
top:0; right:-20px;
content:"#";
text-indent:-999px; overflow:hidden;
display:block;
background:blue;
width:20px; height:135px;
}
现在我想要一个围绕形状的边框。 我该怎么做?
我想要一个像这样的形状:
填充颜色。
答案 0 :(得分:3)
通过改变你的html结构,我可以制作this
<div class="cut-off"></div>
<div class="cut-off2"></div>
.cut-off{
position: relative;
width: 300px;
height: 150px;
border-bottom: 80px red solid;
border-right: 80px transparent solid;
}
.cut-off2{
position: absolute;
z-index: -1;
top:0;
left: 0;
width: 305px;
height: 150px;
border-bottom: 82px blue solid;
border-right: 80px transparent solid;
}
p{
position: absolute;
left: 0;
bottom:-40px;
}
基本上它在现有的下添加了另一个div。对于cuttof效果,它使用边框尺寸。
编辑:我还提供了一种在该地区包含内容的方式。
答案 1 :(得分:0)
试试这个:
<div class="cut-off">content</div>
.cut-off{
position:relative;
height:155px;
width:200px;
background:red;
}
.cut-off:after{
position:absolute;
bottom:0px; right:-20px;
content:".";
text-indent:-999px; overflow:hidden;
display:block;
width:0px; height:0px;
border-top: 20px solid green;
border-right: 20px solid transparent;
}
.cut-off:before{
position:absolute;
top:0; right:-20px;
content:"#";
text-indent:-999px; overflow:hidden;
display:block;
background:blue;
width:20px; height:135px;
}
顺便说一句,我在下一页中找到了这个例子(因此我没有声称代码是我的):http://www.wahnbriefe.net/web-design/css-cut-off-corners
答案 2 :(得分:-1)
我不确定这是否是您正在寻找的,但我认为您可以使用CCS3 border-radius属性来实现它。或许值得一看。也许你可以尝试类似下面的内容:
<div class="cut-off">
<p class="text">Simple text</p>
</div>
.cut-off{
position: relative;
width: 300px;
height: 150px;
border: 1px solid #7A7764;
border-radius: 0 75px 0 0;
}
.text {
margin: 15px;
}