我需要编写一个具有纯css和html轮廓的多边形按钮。这就是我现在所拥有的,但我无法弄清楚如何添加大纲。这也需要在IE中得到支持。我该怎么做?
/**** CSS ***/
#statement .polygon {
width: 290px;
height: 75px;
background: #590f20;
position: relative;
color: #F94141;
text-align: center;
font-size: 1.8em;
line-height: 2.9em;
font-weight: 400;
text-transform: uppercase;
margin-top: 50px;
margin-bottom: 35px;
}
#statement .bottom:before {
content: "";
position: absolute;
top: 0;
left: -50px;
width: 0;
height: 0;
border-left: 25px solid transparent;
border-right: 25px solid #590f20;
border-bottom: 37.5px solid transparent;
}
#statement .bottom:after {
content: "";
position: absolute;
top: 0px;
left: 290px;
width: 0;
height: 0;
border-left: 25px solid #590f20;
border-right: 25px solid transparent;
border-bottom: 37.5px solid transparent;
}
#statement .top:before {
content: "";
position: absolute;
bottom: 37.5px;
left: -50px;
width: 0;
height: 0;
border-left: 25px solid transparent;
border-right: 25px solid #590f20;
border-top: 37.5px solid transparent;
}
#statement .top:after {
content: "";
position: absolute;
bottom: 37.5px;
left: 290px;
width: 0;
height: 0;
border-left: 25px solid #590f20;
border-right: 25px solid transparent;
border-top: 37.5px solid transparent;
}

<div id="statement">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="heading">
<h1></h1>
</div>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-md-3 col-md-offset-4-5">
<a class="button" href="#button">
<div class="polygon bottom top">
Work With Us
</div>
</a>
</div>
</div>
</div>
<!-- /.containter -->
</div>
<!-- /#statement -->
&#13;
答案 0 :(得分:6)
您可以尝试使用css clip-path ploygon,然后添加另一个div来获取边框。
#statement .polygon .outer {
display: inline-block;
width: 290px;
height: 75px;
background: #590f20;
position: relative;
color: #F94141;
text-align: center;
font-size: 1.8em;
line-height: 2.9em;
font-weight: 400;
text-transform: uppercase;
-webkit-clip-path: polygon(30px 80px, 0px 50%, 30px 0px, 260px 0px, 290px 50%, 260px 80px);
clip-path: polygon(30px 80px, 0px 50%, 30px 0px, 260px 0px, 290px 50%, 260px 80px);
-webkit-transform: scale(0.98, 0.95);
transform: scale(0.98, 0.95);
}
#statement .polygon.border {
-webkit-clip-path: polygon(30px 80px, 0px 50%, 30px 0px, 260px 0px, 290px 50%, 260px 80px);
clip-path: polygon(30px 80px, 0px 50%, 30px 0px, 260px 0px, 290px 50%, 260px 80px);
background-color: orange;
}
<div id="statement">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="heading">
<h1></h1>
</div>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-md-3 col-md-offset-4-5">
<a class="button" href="#button">
<div class="polygon border">
<span class="outer">
Work With Us
</span>
</div>
</a>
</div>
</div>
</div>
<!-- /.containter -->
</div>
<!-- /#statement -->
答案 1 :(得分:3)
虽然SVG可能是一个选项,我(必须)添加一个CSS版本。这是一个快速演示,它使用固定高度但可变宽度:
<div>SOME TEXT</div>
{{1}}