css实现环形流程图

css实现环形流程图
效果图
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      :root {
        /* 这个配置步骤之间的间距 */
        --space: 20px;
        /* 这个配置每行几个 */
        --num: 4;
      }

      .row {
        display: block;
        margin-bottom: var(--space);
      }

      .row:nth-child(2n - 1) {
        display: flex;
        justify-content: flex-start;
      }

      .row:nth-child(2n) {
        display: flex;
        flex-direction: row-reverse;
      }

      .step {
        width: calc((100% - var(--space) * (var(--num) - 1)) / var(--num));
        height: 100px;
        background-color: #f2f2f2;
        border: 1px solid red;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
      }

      .row:nth-child(2n - 1) > .step:not(:last-child):after {
        content: "";
        position: absolute;
        top: 50%;
        left: 100%;
        transform: translateY(-50%);
        border-top: 1px solid red;
        width: var(--space);
      }

      .row:nth-child(2n - 1) > .step:not(:last-child) {
        margin-right: var(--space);
      }

      .row:nth-child(2n - 1) > .step:last-child::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        border-right: 1px solid red;
        height: var(--space);
      }

      .row:nth-child(2n) > .step:not(:last-child):after {
        content: "";
        position: absolute;
        top: 50%;
        right: 100%;
        transform: translateY(-50%);
        border-top: 1px solid red;
        width: var(--space);
      }

      .row:nth-child(2n) > .step:not(:last-child) {
        margin-left: var(--space);
      }

      .row:nth-child(2n) > .step:last-child::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        border-right: 1px solid red;
        height: var(--space);
      }
      .row:last-child > .step:last-child::after {
        content: none;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="step">Step 1</div>
        <div class="step">Step 2</div>
        <div class="step">Step 3</div>
        <div class="step">Step 4</div>
      </div>
      <div class="row">
        <div class="step">Step 5</div>
        <div class="step">Step 6</div>
        <div class="step">Step 7</div>
        <div class="step">Step 8</div>
      </div>
        <div class="row">
            <div class="step">Step 9</div>
            <div class="step">Step 10</div>
            <div class="step">Step 11</div>
            <div class="step">Step 12</div>
     </div>
     <div class="row">
        <div class="step">Step 13</div>
        <div class="step">Step 14</div>
        <div class="step">Step 15</div>
        <div class="step">Step 16</div>
     </div>
     <div class="row">
        <div class="step">Step 17</div>
        <div class="step">Step 18</div>
        <div class="step">Step 19</div>
     </div>
    </div>
  </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用CSS实现流程图连接线,可以使用伪元素和transform属性来创建。下面是一种实现方法: 1. 首先,在流程图元素之间添加一个共同的父元素,例如一个div容器。 2. 使用CSS设置该容器为相对定位(position: relative),以便让子元素的绝对定位相对于该容器。 3. 给流程图元素添加一个类名,例如.flow-item,用于选择器定位。 4. 在.flow-item的样式中,使用伪元素before来创建连接线。设定before的宽度、高度和背景颜色,使其成为一条线段。 5. 使用transform属性来调整连接线的位置和角度,可以使用translate()和rotate()方法。将连接线定位到合适的位置并使其与相邻元素对齐。 6. 最后,使用z-index属性来调整连接线与流程图元素之间的层级关系,确保连接线在正确的位置。 以下是一个示例代码: ```html <div class="flow-container"> <div class="flow-item">步骤1</div> <div class="flow-item">步骤2</div> <div class="flow-item">步骤3</div> </div> ``` ```css .flow-container { position: relative; } .flow-item { position: absolute; /* 设置流程图元素的位置 */ } .flow-item:before { content: ''; position: absolute; width: 2px; /* 连接线的宽度 */ background-color: #000; /* 连接线的颜色 */ /* 调整连接线的位置和角度 */ transform: translate(-50%, 0) rotate(90deg); /* 设置连接线的起点和终点位置 */ top: calc(50% + 20px); /* 起点位置 */ bottom: calc(50% + 20px); /* 终点位置 */ left: 50%; /* 连接线的水平位置 */ } /* 设置流程图元素的样式,例如大小、背景颜色等 */ ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值