我需要为此“形状”添加边框。这很难,因为和之前的伪元素的形状是由制成的。我找不到正确的方法。为此“形状”添加边框
我需要实现:
的代码,我到目前为止有:
https://jsfiddle.net/jimmyadaro/xfcjfz3d/
#octagon {
width: 300px;
height: 200px;
background: red;
position: relative;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
display: block;
}
#octagon:before,
#octagon:after {
content: "";
position: absolute;
left: 0;
right: 0;
}
#octagon:before {
top: 0;
border-bottom: 30px solid red;
border-left: 30px solid #fff;
border-right: 30px solid #fff;
}
#octagon:after {
bottom: 0;
border-top: 30px solid red;
border-left: 30px solid #fff;
border-right: 30px solid #fff;
}
<div id="octagon"></div>
我试着用阴影和没有成功的轮廓。
感谢您的阅读。
注:如果有问题,我将使用纯色背景色。
此链接可以帮助你http://stackoverflow.com/questions/34641588/how-do-i-give-a-css-octagon-shape-一个全国性的 – Geeky
谢谢@geeky,我已经看到,但看起来不可扩展。我的意思是,它不能是600x200px。至少在我尝试过的方式中。 –
相关 - http://stackoverflow.com/questions/34644437/how-do-i-add-a-border-to-an-8-point-star-css-shape但SVG在这里是最优的。 –