html - 将方形 div 与圆形 div 无缝连接

标签 html css

我构建了一个带有“步骤”的进度条,这些“步骤”由一个栏(div)连接起来。如图所示,我需要让栏无缝地加入到每个“步骤”中。有没有办法做到这一点?例如。通过 ::before::after,而不引入一些严重的定位黑客?

enter image description here

最佳答案

您可以创建:after伪元素比每个圆之间的空间稍长,然后将其定位,使其位于左右圆下方。

如果边距为20px然后你可以创建每一行 44px例如并设置 right: 2px这样就有 2px两侧圆圈下的线。

ul {
  display: flex;
  font-size: 20px;
  list-style: none;
}
li {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: lightblue;
  position: relative;
  line-height: 70px;
  text-align: center;
  margin: 0 20px;
}
li:not(:last-child):after {
  content: '';
  height: 15px;
  width: 44px;
  background: green;
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translate(100%, -50%);
  z-index: -1;
}
<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
</ul>

关于html - 将方形 div 与圆形 div 无缝连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44617196/

相关文章:

html - IE6 中的任意列大小和缺失边框

html - 表类在 css/html 中不起作用

css - 如何让页脚停留在网页底部?

html - 我的 div 元素忽略了带有长文本的 CSS 样式

html - 根据屏幕分辨率更改 div 位置(flexbox?)

css - "img"中 "a"的中间垂直对齐

css - SCSS 后台无效的属性值

c# - 将 IQueryable<int> 转换为 <int>

jquery 悬停一个 div 并在另一个 div 上显示图像效果

css - 表格中段落中的自动换行换行符