请看下面我现在正在使用的CSS规则,用于创建带有“箭头效果”的矩形框,左右两侧均有箭头:
CSS:
.hexagon {
position: relative;
width: 60px;
height: 34.64px;
background-color: #64C7CC;
margin: 17.32px 0;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
width: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
}
.hexagon:before {
bottom: 100%;
border-bottom: 17.32px solid #64C7CC;
}
.hexagon:after {
top: 100%;
width: 0;
border-top: 17.32px solid #64C7CC;
}
HTML:
<div class="hexagon"></div>
当我需要一个宽度为60px
,高度为22px
的矩形,并且两侧还有三角形时,有谁能帮我解决这个问题?
.hexagon
元素的高度变为 22px 而不是当前的34.64px,三角形的边框宽度应该是多少。可能需要数学定理来计算矩形区域高度基础上的三角形区域的边长。 - Harry