.star {
width: 0px;
height: 0px;
border-bottom: 9.51px solid yellow;
border-left: 3.09px solid transparent;
border-right: 3.09px solid transparent;
position: relative;
}
.star::before, .star::after {
content: "";
width: 0px;
height: 0px;
border-bottom: 9.51px solid yellow;
border-left: 13.09px solid transparent;
border-right: 13.09px solid transparent;
}
.star::before {
transform: rotate(-36deg);
position: absolute;
top: 8.6px;
left: -13.3852px;
}
.star::after {
transform: rotate(36deg);
position: absolute;
top: 8.6px;
left: -12.7948px;
}
/* 泛化:假设星型边长为 a,那么可以计算得到样式数据如下:
.star {
width: 0px;
height: 0px;
border-bottom: 【0.951a】px solid yellow;
border-left: 【0.309a】px solid transparent;
border-right: 【0.309a】px solid transparent;
position: relative;
}
.star::before, .star::after {
content: "";
width: 0px;
height: 0px;
border-bottom: 【0.951a】px solid yellow;
border-left: 【1.309a】px solid transparent;
border-right: 【1.309a】px solid transparent;
}
.star::before {
transform: rotate(-36deg);
position: absolute;
top: 【0.86a】px;
left: 【-1.33852a】px;
}
.star::after {
transform: rotate(36deg);
position: absolute;
top: 【0.86a】px;
left: 【-1.27948a】px;
}
说明:由于在计算过程中只保留有限小数,所以星型边长越大,误差越大 */