如何使用 CSS 使用 dotted/dashed 行填充两个 div 之间的水平 space

How to fill the horizontal space between two divs using dotted/dashed line using CSS

this is what I want to achieve

我试过了,但我无法改变破折号之间的距离。 此外,圆圈和虚线的大小不会根据屏幕大小而改变。

这是我到目前为止所做的: see the gap difference between the dashes

代码如下:

      <div id="getStarted" className={styles.getStarted}>
    <h3>How to get started?</h3>
    <div className={styles.Icons}>
      <div className={styles.circle}>
      
      </div>
      <div className={styles.dash}></div>
      <div className={styles.circle}>
      
      </div>
       <div className={styles.dash}></div>
       <div className={styles.circle}>
      
      </div>
    </div>
  </div>

这是 css 样式:

    .getStarted {
  justify-content: center;
  align-items: center;
  text-align: center;

  h3 {
    color: #006ebe;
    font-size: 2.3vw;
    margin-bottom: 100px;
  }

  .Icons {
      gap: 2vw;
    display: flex;
    justify-content: center;

.circle {
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 10px;
  background: #0093ff;
  border: 3px solid #0093ff;
  color: white;
  text-align: center;
  font: 20px Poppins, sans-serif;
  font-weight: 600;
  line-height: 22px;
}
    .dash {
      
      width: 10%;
      border-top: 4px dotted #006ebe;
      margin-top: 20px;
      transform: rotate(-0.07deg);
    }
  }
}

您的模板看起来非常像使用 stroke-dasharray and round strike-linecap

的 svg 行

.getStarted {
  justify-content: center;
  align-items: center;
  text-align: center;
}
h3 {
  color: #006ebe;
  font-size: 2.3vw;
  margin-bottom: 100px;
}

.Icons {
  gap: 2vw;
  display: flex;
  justify-content: center;
}

.circle {
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 10px;
  background: #0093ff;
  border: 3px solid #0093ff;
  color: white;
  text-align: center;
  font: 20px Poppins, sans-serif;
  font-weight: 600;
  line-height: 22px;
}

.dash {
  width: 10%;
  transform: rotate(-0.07deg);
}
.dash line {
  stroke: #0093ff;
  stroke-dasharray: 0.5 3.2;
  stroke-linecap: round;
}
<div id="getStarted" class="getStarted">
  <h3>How to get started?</h3>
  <div class="Icons">
    <div class="circle">

    </div>
    <svg class="dash" viewBox="-10 -5 20 10"><line x1="-9" x2="9"></line></svg>
    <div class="circle">

    </div>
     <svg class="dash" viewBox="-10 -5 20 10"><line x1="-9" x2="9"></line></svg>
     <div class="circle">

    </div>
  </div>
</div>

您可以更改 CSS。

CSS 示例:

.getStarted {
  justify-content: center;
  align-items: center;
  text-align: center;
}

  h3 {
    color: #006ebe;
    font-size: 2.3vw;
    margin-bottom: 100px;
  }

  .Icons {
    display: flex;
    justify-content: center;
  }

.circle {
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 10px;
  background: #0093ff;
  border: 3px solid #0093ff;
  color: white;
  text-align: center;
  font: 20px Poppins, sans-serif;
  font-weight: 600;
  line-height: 22px;
  margin-left: 6px;
  margin-right: 6px;
}
    .dash {
      
  width: 20%;
  border-top: 4px dotted #006ebe;
    margin: 20px 2px 0 2px;
  transform: rotate(-0.07deg);
    }

HTML

      <div id="getStarted" className={styles.getStarted}>
    <h3>How to get started?</h3>
    <div className={styles.Icons}>
      <div className={styles.circle}>
      
      </div>
      <div className={styles.dash}></div>
      <div className={styles.circle}>
      
      </div>
       <div className={styles.dash}></div>
       <div className={styles.circle}>
      
      </div>
    </div>
  </div>

.getStarted {
  justify-content: center;
  align-items: center;
  text-align: center;
}

  h3 {
    color: #006ebe;
    font-size: 2.3vw;
    margin-bottom: 100px;
  }

  .Icons {
    display: flex;
    justify-content: center;
  }

.circle {
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 10px;
  background: #0093ff;
  border: 3px solid #0093ff;
  color: white;
  text-align: center;
  font: 20px Poppins, sans-serif;
  font-weight: 600;
  line-height: 22px;
  margin-left: 6px;
  margin-right: 6px;
}
    .dash {
      
  width: 20%;
  border-top: 4px dotted #006ebe;
    margin: 20px 2px 0 2px;
  transform: rotate(-0.07deg);
    }
<div class="getStarted" id="getStarted">
<h3>How to get started?</h3>

<div class="Icons">
<div class="circle"></div>

<div class="dash"></div>

<div class="circle"></div>

<div class="dash"></div>

<div class="circle"></div>
</div>
</div>

通过使用此答案 How to increase space between dotted border dots 并更改 background-size 属性 您可以更改破折号之间的间距。通过使用 vw 单位,您可以通过调整页面大小来更改破折号。

.getStarted {
  justify-content: center;
  align-items: center;
  text-align: center;
}
h3 {
  color: #006ebe;
  font-size: 2.3vw;
  margin-bottom: 100px;
}

.Icons {
  gap: 2vw;
  display: flex;
  justify-content: center;
}
.circle {
  border-radius: 50%;
  width: 20px;
  height: 20px;
  padding: 10px;
  background: #0093ff;
  border: 3px solid #0093ff;
  color: white;
  text-align: center;
  font: 20px Poppins, sans-serif;
  font-weight: 600;
  line-height: 22px;
}
.dash {
  width: 10%;
  background-image: linear-gradient(
    to right,
    #0093ff 35%,
    rgba(255, 255, 255, 0) 0%
  );
  background-position: center;
  background-size: 1.6vw 0.6vw;
  background-repeat: repeat-x;
}
<div id="getStarted" class='getStarted'>
  <h3>How to get started?</h3>
  <div class='Icons'>
      <div class=' circle'>

  </div>
  <div class='dash'></div>
  <div class='circle'>

  </div>
  <div class='dash'></div>
  <div class='circle'>

  </div>
</div>
</div>