css画正六边形

css画正六边形_第1张图片

<div class="hexagon">
	 <div class='one'>1div>
	 <div class='two'>2div>
	 <div class='three'>3div>
div>
.hexagon{
   	 position:relative;width:88px;
 }
.one {
	 width: 88px;
	 height: 50px;
	 border-left: 1px solid red;
	 border-right: 1px solid red;
}
.two {
	 position: absolute;
	 width: 88px;
	 height: 50px;
	 top: 0;
	 transform: translate(-50%, -50%);
	 transform: rotate(60deg);
	 border-left: 1px solid red;
	 border-right: 1px solid red;
}
.three {
	 position: absolute;
	 width: 88px;
	 height: 50px;
	 top: 0;
	 transform: translate(-50%, -50%);
	 transform: rotate(300deg);
	 border-left: 1px solid red;
	 border-right: 1px solid red;
}

css画正六边形_第2张图片

 .hexagon{
    position:relative;width:88px;
    .one {
      width: 50px;
      height: 88px;
      border-top: 1px solid red;
      border-bottom: 1px solid red;
    }
    .two {
      position: absolute;
      width: 50px;
      height: 88px;
      border-top: 1px solid red;
      border-bottom: 1px solid red;
      top: 0;
      transform: translate(-50%, -50%);
      transform: rotate(60deg);
    }
    .three {
      position: absolute;
      width: 50px;
      height: 88px;
      border-top: 1px solid red;
      border-bottom: 1px solid red;
      top: 0;
      transform: translate(-50%, -50%);
      transform: rotate(300deg);
    }
  }

参考链接https://blog.csdn.net/qq_42606051/article/details/80949741###

你可能感兴趣的:(css)