首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有透明度的CSS分步进度条

具有透明度的CSS分步进度条
EN

Stack Overflow用户
提问于 2018-09-13 19:33:20
回答 1查看 1.2K关注 0票数 1

有人能帮我在一个只使用CSS的阶梯进度栏中设置一个透明的圆圈边框吗?

有很多好的开端,比如这篇文章:创建由线连接的CSS3圆

这个网站是:https://www.cssscript.com/animated-step-progress-bar-pure-javascript/

或者这个网站:http://christabor.github.io/css-progress-wizard/

我的问题是,我需要一个透明的边界周围的圆圈,这条线通过。在本例中,绿色线通过圆圈灰色边框的顶部。

这是一支笔,你可以从上面的一个例子开始。https://codepen.io/anon/pen/oPydjx

代码语言:javascript
复制
body {
  font-family: 'Lato', sans-serif;
  font-size: 20px;
  padding: 20px;
}

@media handheld,
screen and (max-width: 400px) {
  .container {
    margin: 0;
    width: 100%;
  }
  .progress-indicator.stacked {
    display: block;
    width: 100%;
  }
  .progress-indicator.stacked>li {
    height: 80px;
  }
}

.flexer,
.progress-indicator {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex
}

.flexer-element,
.progress-indicator>li {
  -ms-flex: 1;
  -webkit-flex: 1;
  -moz-flex: 1;
  flex: 1
}

.progress-indicator>li {
  list-style: none;
  text-align: center;
  width: auto;
  padding: 0;
  margin: 0;
  position: relative;
  text-overflow: ellipsis;
  color: #bbb;
  display: block
}

.progress-indicator>li.completed,
.progress-indicator>li.completed .bubble {
  color: #65d074
}

.progress-indicator>li .bubble {
  border-radius: 1000px;
  width: 20px;
  height: 20px;
  background-color: #bbb;
  display: block;
  margin: 0 auto .5em;
  border-bottom: 1px solid #888
}

.progress-indicator>li .bubble:after,
.progress-indicator>li .bubble:before {
  display: block;
  position: absolute;
  top: 9px;
  width: 100%;
  height: 3px;
  content: '';
  background-color: #bbb
}

.progress-indicator>li.completed .bubble,
.progress-indicator>li.completed .bubble:after,
.progress-indicator>li.completed .bubble:before {
  background-color: #65d074;
  border-color: #247830
}

.progress-indicator>li .bubble:before {
  left: 0
}

.progress-indicator>li .bubble:after {
  right: 0
}

.progress-indicator>li:first-child .bubble:after,
.progress-indicator>li:first-child .bubble:before {
  width: 50%;
  margin-left: 50%
}

.progress-indicator>li:last-child .bubble:after,
.progress-indicator>li:last-child .bubble:before {
  width: 50%;
  margin-right: 50%
}

.progress-indicator>li.active,
.progress-indicator>li.active .bubble {
  color: #337AB7
}

.progress-indicator>li.active .bubble,
.progress-indicator>li.active .bubble:after,
.progress-indicator>li.active .bubble:before {
  background-color: #337AB7;
  border-color: #122a3f
}

@media handheld,
screen and (max-width: 400px) {
  .progress-indicator {
    font-size: 60%
  }
}
代码语言:javascript
复制
<html>

<body>

  <ul class="progress-indicator">
    <li class="completed">
      <span class="bubble"></span> Step 1. <br><small>(complete)</small>
    </li>
    <li class="completed">
      <span class="bubble"></span> Step 2. <br><small>(complete)</small>
    </li>
    <li class="active">
      <span class="bubble"></span> Step 3. <br><small>(active)</small>
    </li>
    <li>
      <span class="bubble"></span> Step 4.
    </li>
    <li>
      <span class="bubble"></span> Step 5.
    </li>
  </ul>

</body>

</html>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-13 19:41:27

因为线条绝对是位置元素,所以它们出现在气泡上方。您可以在气泡中添加一个盒影以获得以下效果:

代码语言:javascript
复制
.progress-indicator>li .bubble {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);

  border-radius: 50%;
  width: 20px;
  height: 20px;
  background-color: #bbb;
  display: block;
  margin: 0 auto .5em;
  border-bottom: 1px solid #888;
}

示例:

代码语言:javascript
复制
body {
  font-family: 'Lato', sans-serif;
  font-size: 20px;
  padding: 20px;
}

@media handheld,
screen and (max-width: 400px) {
  .container {
    margin: 0;
    width: 100%;
  }
  .progress-indicator.stacked {
    display: block;
    width: 100%;
  }
  .progress-indicator.stacked>li {
    height: 80px;
  }
}

.flexer,
.progress-indicator {
  display: flex
}

.flexer-element,
.progress-indicator>li {
  flex: 1
}

.progress-indicator>li {
  list-style: none;
  text-align: center;
  width: auto;
  padding: 0;
  margin: 0;
  position: relative;
  text-overflow: ellipsis;
  color: #bbb;
  display: block
}

.progress-indicator>li.completed,
.progress-indicator>li.completed .bubble {
  color: #65d074
}

.progress-indicator>li .bubble {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
  
  border-radius: 50%;
  width: 20px;
  height: 20px;
  background-color: #bbb;
  display: block;
  margin: 0 auto .5em;
  border-bottom: 1px solid #888;
}

.progress-indicator>li .bubble:after,
.progress-indicator>li .bubble:before {
  display: block;
  position: absolute;
  top: 9px;
  width: 100%;
  height: 3px;
  content: '';
  background-color: #bbb
}

.progress-indicator>li.completed .bubble,
.progress-indicator>li.completed .bubble:after,
.progress-indicator>li.completed .bubble:before {
  background-color: #65d074;
  border-color: #247830
}

.progress-indicator>li .bubble:before {
  left: 0
}

.progress-indicator>li .bubble:after {
  right: 0
}

.progress-indicator>li:first-child .bubble:after,
.progress-indicator>li:first-child .bubble:before {
  width: 50%;
  margin-left: 50%
}

.progress-indicator>li:last-child .bubble:after,
.progress-indicator>li:last-child .bubble:before {
  width: 50%;
  margin-right: 50%
}

.progress-indicator>li.active,
.progress-indicator>li.active .bubble {
  color: #337AB7
}

.progress-indicator>li.active .bubble,
.progress-indicator>li.active .bubble:after,
.progress-indicator>li.active .bubble:before {
  background-color: #337AB7;
  border-color: #122a3f
}

@media handheld,
screen and (max-width: 400px) {
  .progress-indicator {
    font-size: 60%
  }
}
代码语言:javascript
复制
<ul class="progress-indicator">
  <li class="completed">
    <span class="bubble"></span> Step 1. <br><small>(complete)</small>
  </li>
  <li class="completed">
    <span class="bubble"></span> Step 2. <br><small>(complete)</small>
  </li>
  <li class="active">
    <span class="bubble"></span> Step 3. <br><small>(active)</small>
  </li>
  <li>
    <span class="bubble"></span> Step 4.
  </li>
  <li>
    <span class="bubble"></span> Step 5.
  </li>
</ul>

</body>

</html>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52320603

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档