• css实现六边形


    先看图,想实现这样一个效果图:
    在这里插入图片描述

            <div class="cellular center">
              
              <div class="line1">
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1 error-qudao">
                        <p>
                          <span>1span>
                          <span>1/18span>
                        p>
                      div>
                    div>
                  div>
                div>
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1">
                        <p>
                          <span>2span>
                          <span>15/15span>
                        p>
                      div>
                    div>
                  div>
                div>
              div>
              
              <div class="line2">
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1">
                        <p>
                          <span>3span>
                          <span>6/6span>
                        p>
                      div>
                    div>
                  div>
                div>
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1">
                        <p>
                          <span>centerspan>
                        p>
                      div>
                    div>
                  div>
                div>
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1">
                        <p>
                          <span>5span>
                          <span>20/20span>
                        p>
                      div>
                    div>
                  div>
                div>
              div>
              
              <div class="line3">
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1">
                        <p>
                          <span>6span>
                          <span>0/9span>
                        p>
                      div>
                    div>
                  div>
                div>
                <div class="box1">
                  <div class="box2">
                    <div class="box3">
                      <div class="bar1">
                        <p>
                          <span>7span>
                          <span>13/13span>
                        p>
                      div>
                    div>
                  div>
                div>
              div>
            div>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94

    css(scss)

        .cellular {
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          width: 30%;
          .line1,
          .line2,
          .line3 {
            display: flex;
          }
          .line2,
          .line3 {
            margin-top: -22px;
          }
          .box1,
          .box2,
          .box3 {
            // 宽高比例必须是4:5
            width: 80px;
            height: 100px;
            overflow: hidden;
          }
          .box1 {
            transform: rotate(120deg);
            margin-left: 10px;
          }
          .box2 {
            transform: rotate(-60deg);
          }
          .box3 {
            transform: rotate(-60deg);
            // background: linear-gradient(87deg, #4c92ff, #90dfff00);
            background: linear-gradient(323deg, #4c92ff, rgba(144, 223, 255, 0));
            border: none;
            .bar1 {
              display: flex;
              justify-content: space-around;
              width: 100%;
              align-items: center;
              color: #ffffff;
              height: 100%;
              padding: 0.06rem;
              border-radius: 0.05rem;
              //   background: #91f2612e;
              //   box-shadow: 0px 2px 12px 1px #a7e88773 inset;
              //   color: #46be52;
              color: #ffffff;
              font-weight: bold;
              background-size: 100% 100%;
              position: relative;
              .iconfont {
                font-size: 0.25rem;
              }
              p {
                margin: 0;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                width: 75%;
              }
              span {
                // width: 42%;
                // font-size: 0.08rem;
                // width: 70%;
                // font-size: 0.08rem;
                text-align: center;
              }
            }
            .error-qudao {
              color: #f5f64c;
              background: linear-gradient(323deg, #f94343, #ffc722e3);
            }
          }
          .box3 img {
            width: 100%;
            height: 100%;
          }
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80

    还有一种实现六边形的方法:一个长方形加左右各一个三角形。

       <div class="one">div>
    
       .one{
            width: 120px;
            height: 208px;
            background-color: aqua;
            position: relative;
            margin: 0 100px;
        }
        .one:before{
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            top: 0;
            left: -60px;
            border-top: 104px solid transparent;
            border-bottom: 104px solid transparent;
            border-right: 60px #0f0 solid;
            border-left:none;
        }
        .one:after{
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            top: 0;
            left: 120px;
            border-top: 104px solid transparent;
            border-bottom: 104px solid transparent;
            border-right: none;
            border-left:60px #0f0 solid;
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33

    参考:http://t.zoukankan.com/fmixue-p-15130382.html

  • 相关阅读:
    Rn开发社区推荐组件
    最佳实践:Websocket 长连接状态如何保持
    其他服务注册与发现
    【XGBoost】第 2 章:深度决策树
    IDEA这样配置Maven:让你一遍就能学会!
    jenkins发布java项目和执行shell脚本nohup的总结
    IO系列第一章——BIO
    【脑源成像】术前癫痫的电源成像 评价:现状与未来展望
    小红书和抖音的流量机制是什么?
    Transformer中的位置编码PE(position encoding)
  • 原文地址:https://blog.csdn.net/qq_44441669/article/details/126260494