Tôi cần mã một nút đa giác có đường viền với css và html thuần túy. Đây là những gì tôi có ngay bây giờ nhưng tôi không thể tìm ra cách thêm đường viền. Điều này cũng cần được hỗ trợ trong IE. Làm thế nào để tôi làm điều này?Nút đa giác có CSS tinh khiết
/**** 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 -->
tôi sẽ khuyên bạn sử dụng svg. Hỗ trợ trở lại IE9. Vì bạn đang sử dụng các lớp giả, tôi cho rằng bạn không hỗ trợ bất cứ điều gì cũ hơn thế. –
điều này có thể hữu ích: https://css-tricks.com/examples/ShapesOfCSS/ –
Bạn đã sử dụng hướng dẫn "biên giới" cho nút vẽ và do đó không thể thêm bất kỳ đường viền nào. Như đã nói ở trên, sẽ tốt hơn nếu sử dụng phần tử SVG - sự sụp đổ chính của nút (và bất kỳ hình đa giác nào được viết bằng CSS) là nó vẫn có mặt nạ hình chữ nhật. – SzybkiSasza