html - 在div之间添加边框线

标签 html css

如何使用 CSS 在每个圆 div 之间添加边框线?圆圈和边界线也必须具有响应性。我试图添加边框线,但它甚至不显示。该线必须在圆圈中间居中。

.default-step {
  height: 120px;
  max-width: 120px;
  text-align: center;
  vertical-align: middle;
  border: 5px solid #3A83C5;
  border-radius: 50%;
  background: #FFF;
  color: #084085;
  font: 16px "josefin sans", arial;
  cursor: default;
  line-height: 3em;
  justify-content: space-between;
  flex: 1 1 auto;
  align-items: stretch;
}

.steps {
  width: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  align-items: stretch;
}

.steps div:not(:last-child) {
  border-bottom: 4px solid #0369B3;
}
<div class="steps">

  <div id="circle-step-1" class="default-step">STEP 1</div>

  <div id="circle-step-2" class="default-step">STEP2</div>

  <div id="circle-step-3" class="default-step">STEP 3</div>

  <div id="circle-step-4" class="default-step">STEP 4</div>

  <div id="circle-step-5" class="default-step">STEP 5</div>

</div>

谢谢!

最佳答案

也许容器上有一个简单的背景:

background:linear-gradient(#084085,#084085) center/100% 5px no-repeat;

.default-step {
  height: 100px;
  max-width: 100px;
  text-align: center;
  border: 5px solid #3A83C5;
  border-radius: 50%;
  background: #FFF;
  color: #084085;
  line-height: 3em;
  flex: 1 1 auto;
}

.steps {
  display: flex;
  justify-content: space-between;
  /*Add this code*/
  background:linear-gradient(#084085,#084085) center/100% 5px no-repeat;
}
<div class="steps">

  <div id="circle-step-1" class="default-step">STEP 1</div>

  <div id="circle-step-2" class="default-step">STEP2</div>

  <div id="circle-step-3" class="default-step">STEP 3</div>

  <div id="circle-step-4" class="default-step">STEP 4</div>

  <div id="circle-step-5" class="default-step">STEP 5</div>

</div>


奖金

如果你想要箭头,你可以试试这个:

.default-step {
  height: 100px;
  max-width: 100px;
  text-align: center;
  border: 5px solid #3A83C5;
  border-radius: 50%;
  background: #FFF;
  color: #084085;
  line-height: 3em;
  flex: 1 1 auto;
  position:relative;
  box-sizing:border-box;
}
.default-step:not(:first-child):before {
  content:"";
  position:absolute;
  height:20px;
  width:10px;
  top:calc(50% - 10px);
  left:-15px;
  background-image:
   linear-gradient(to bottom right,#084085 50%, white 0),
   linear-gradient(to top right,#084085 50%, white 0);
  background-position:bottom, top;
  background-size:100% 50%;
  background-repeat:no-repeat;
}

.steps {
  display: flex;
  justify-content: space-between;
  /*Add this code*/
  background:linear-gradient(#084085,#084085)0 50%/100% 5px no-repeat;
}
<div class="steps">

  <div id="circle-step-1" class="default-step">STEP 1</div>

  <div id="circle-step-2" class="default-step">STEP2</div>

  <div id="circle-step-3" class="default-step">STEP 3</div>

  <div id="circle-step-4" class="default-step">STEP 4</div>

  <div id="circle-step-5" class="default-step">STEP 5</div>

</div>

下面是带有透明度的完整代码:

body {
  background:linear-gradient(to right,pink,lightblue);
}
.default-step {
  height: 100px;
  max-width: 100px;
  text-align: center;
  border: 5px solid #3A83C5;
  border-radius: 50%;
  color: #084085;
  line-height: 3em;
  flex: 1 1 auto;
  position:relative;
  box-sizing:border-box;
}
.default-step:not(:first-child):before {
  content:"";
  position:absolute;
  height:20px;
  width:10px;
  top:calc(50% - 10px);
  left:-15px;
  background-image:
   linear-gradient(to bottom right,#084085 50%, transparent 50.5%),
   linear-gradient(to top right,#084085 50%, transparent 50.5%);
  background-position:bottom, top;
  background-size:100% 50%;
  background-repeat:no-repeat;
}

.steps {
  display: flex;
  justify-content: space-between;
  /*Add this code*/
  background:linear-gradient(to right, transparent 100px, #084085 100px, #084085 calc(100% - 5px),transparent 0) 0 50%/calc((100% - 100px)/4) 5px repeat-x;
}
<div class="steps">

  <div id="circle-step-1" class="default-step">STEP 1</div>

  <div id="circle-step-2" class="default-step">STEP2</div>

  <div id="circle-step-3" class="default-step">STEP 3</div>

  <div id="circle-step-4" class="default-step">STEP 4</div>

  <div id="circle-step-5" class="default-step">STEP 5</div>

</div>

关于html - 在div之间添加边框线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50001316/

相关文章:

html - map 覆盖了切换按钮

jquery - <select> 标签需要选项上的垂直滚动条

html - 使用 flexbox 将元素包装到新行/行

使用 Backdrop JS 进行 CSS 视觉回归测试 - 无法运行 grunt :reference or grunt:test

javascript - 将鼠标悬停在 HTML/JS/JQUERY 中的列表上时弹出图像

html - Bootstrap 下拉菜单不起作用

html - 为什么内容器与外容器不相配?

html - ASP.NET MVC 4 捆绑空白 - 格式化输出

html - 在此上下文中,元素输入不允许作为元素 ul 的子元素

javascript - 如何显示带有id的元素并隐藏其他元素