一、六边形的两种画法
(1)画法一
.hexagon-1 {
position: relative;
width: 100px;
height: 173.2px;
margin: 0 auto;
background-color: red;
}
.hexagon-1::before,
.hexagon-1::after {
content: "";
display: block;
position: absolute;
top: 0;
width: 0;
height: 0;
border-top: 86.6px solid transparent;
border-bottom: 86.6px solid transparent;
}
.hexagon-1::before {
left: -50px;
border-right: 50px solid green;
}
.hexagon-1::after {
right: -50px;
border-left: 50px solid green;
}
(2)画法二
.hexagon-2 {
position: relative;
width: 100px;
height: 173.2px;
margin: 0 auto;
background-color: red;
}
.hexagon-2::before,
.hexagon-2::after {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 173.2px;
}
.hexagon-2::before {
transform: rotate(60deg);
background-color: green;
}
.hexagon-2::after {
transform: rotate(-60deg);
background-color: purple;
}
(3)画法三
.hexagon-3 {
position: relative;
width: 100px;
height: 173.2px;
margin: 0 auto;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
box-sizing: border-box;
}
.hexagon-3::before,
.hexagon-3::after {
content: "";
display: block;
position: absolute;
top: -1px;
left: 0;
width: 100px;
height: 173.2px;
box-sizing: border-box;
}
.hexagon-3::before {
transform: rotate(60deg);
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
.hexagon-3::after {
transform: rotate(-60deg);
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}