html - 创建连接的圈子

标签 html css

我需要创建这个图像:

enter image description here

它包含带有线条的圆圈。我画了红色方框来表明它们是 div,因为当它在移动设备上显示时应该是这样的:

enter image description here

我试过 what this post says但它对我不起作用,因为 li 不会在同一个 div 中。

这是我的代码:

.steps {
  max-width: 1170px;
  margin: auto;
  overflow: auto;
}
.step-1,
.step-2,
.step-3,
.step-4 {
  width: 25%;
  float: left;
}
<div class="steps">
  <div class="step-1">
    <div class="step-image">
      <img src="step1.jpg">
    </div>
    <div class="step-title">Measure Your Space</div>
    <div class="step-number">1
    </div>
  </div>

  <div class="step-2">
    <div class="step-image">
      <img src="step2.jpg">
    </div>
    <div class="step-title">Your Kitchen is Designed</div>
    <div class="step-number">2</div>
  </div>

  <div class="step-3">
    <div class="step-image">
      <img src="step3.jpg">
    </div>
    <div class="step-title">Your Materials are Shipped</div>
    <div class="step-number">3</div>
  </div>

  <div class="step-4">
    <div class="step-image">
      <img src="step4.jpg">
    </div>
    <div class="step-title">Start contruction of your dream kitchen</div>
    <div class="step-number">4</div>
  </div>
</div>

如何创建用线连接的圆圈?

最佳答案

以下解决方案适用于带有线条的版本。
要删除行,请将 content: none; 放在 media-query 下。

section {
  display: inline-block;
  width: 25%;
  text-align: center;
}

div {
  margin: .5em;
  border: 1px solid red;
  padding: .5em;
  position: relative;
}

a {
  display: inline-block;
  height: 2em;
  width: 2em;
  line-height: 2em;
  text-align: center;
  border: 1px solid;
  border-radius: 50%;
  background: silver;
}

a:before, a:after {
  content: "";
  position: absolute;
  border-top: 1px solid;
  margin-top: 1em;
  z-index: -1;
}

a:before {
  margin-left: -1px;
  left: -.5em;
  right: 50%;
}

a:after {
  margin-right: -1px;
  left: 50%;
  right: -.5em;
}

section:first-child a:before,
section:last-child a:after {
  content: none;
}
<main>
  <section>
    <div>
      <p>Some content</p>
      <a>1</a>
    </div>
  </section><section>
    <div>
      <p>Some content</p>
      <a>2</a>
    </div>
  </section><section>
    <div>
      <p>Some content</p>
      <a>3</a>
    </div>
  </section><section>
    <div>
      <p>Some content</p>
      <a>4</a>
    </div>
  </section>
</main>

关于html - 创建连接的圈子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41309433/

相关文章:

html - 如何让图像显示在每个 <li> 上方

javascript - 如何使用 jQuery Closest() 函数获取元素的 Id

Java 套接字 HTML 响应

html - CSS:在容器内按奇数/偶数顺序 float 图像

javascript - 将 ID 或 Class 设置为单选按钮变体

php - 使用 PHP 提交表单时 MySQL 数据库未更新

css - 使用 css 减少 <div> block 的宽度

html - 水平滚动条 HTML

javascript - 在不同的浏览器和设备上呈现不同的 HTML

javascript - 手机上的菜单在不应该触发的时候触发