我希望用CSS3制作一个类似于以下图片的具有边框、圆角和透明背景的六边形:
我无法做到同时满足圆角和边框的效果。
这是我的代码:
#hexagon-circle {
position: relative;
margin: 1em auto;
width: 10em;
height: 17.32em;
border-radius: 1em/.5em;
background: red;
transition: opacity .5s;
cursor: pointer;
}
#hexagon-circle:before {
position: absolute;
width: inherit;
height: inherit;
border-radius: inherit;
background: inherit;
content: '';
-webkit-transform: rotate(60deg); /* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(60deg); /* IE 9 */
transform: rotate(60deg); /* Firefox 16+, IE 10+, Opera */
}
#hexagon-circle:after {
position: absolute;
width: inherit;
height: inherit;
border-radius: inherit;
background: inherit;
content: '';
-webkit-transform: rotate(-60deg); /* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(-60deg); /* IE 9 */
transform: rotate(-60deg); /* Firefox 16+, IE 10+, Opera */
}
<div id="hexagon-circle"></div>