如何使用HTML和CSS在同一进度栏中添加多个圈子?

时间:2018-08-22 22:21:56

标签: html css css3 progress-bar

我正在尝试根据此UX sample

创建一个到当前日期为止有多个资金的进度条

到目前为止,我已经可以显示第一个圆圈。这是我的代码的输出output

HTML:

<div class={`col-md-12`}>
  <h3 class="line-bottom mt-0">Money Earned to Date</h3>
  <div class="row">
    <div class="col-md-6">
      <div class="progress">
        <div class="progress-bar" style="width: 12%; background: #ed687c;">
          <span class="progress-icon fa fa-dollar-sign" style="color: #707070; border-color: #707070;"></span>
          <div class="progress-value">$100</div>
        </div>
      </div>
    </div>
  </div>
</div>

CSS

.progressbar-title {
    font-size: 14px;
    color: #848484;
    text-transform: capitalize;
}
.progress {
    height: 30px;
    overflow: visible;
    background: #f4bc25;
    margin-top: 25px;
    margin-bottom: 40px;
    border-radius: 20px;
    border: 1px solid #707070;
}
.progress .progress-bar {
    position: relative;
}
.progress .progress-icon {
    width: 55px;
    height: 53px;
    line-height: 47px;
    border-radius: 50%;
    font-size: 20px;
    position: absolute;
    top: -14px;
    right: 0;
    padding: 0 19px;
    background: #fff;
    border-width: 3px;
    border-style: solid;
    color: #707070;
}
.progress-value {
    font-size: 15px;
    color: #000;
    position: absolute;
    top: 45px;
    right: 11px;
}

有人可以帮我完成UX上的其余部分吗?

2 个答案:

答案 0 :(得分:0)

我终于能够自己完成其余部分。 See screenshot

万一有兴趣的人,这里是完整的代码:

HTML:

<div class="col-md-12">
  <h3 class="heading">Money Earned to Date</h3>
  <div class="row">
    <div class="col-md-10">
      <div class="checkout-wrap">
        <ul class="checkout-bar">
          <li class="visited first">
            <a href="#">$100</a>
          </li>
          <li class="previous first">$500</li>
          <li class="active">
            $1,000
            <div class="progress-bar" style="width: 85%; background: #cc504c;"></div>
            <div class="progress-value">$1,500</div>
          </li>
          <li class="next">$2,500</li>
          <li>$5,000</li>
        </ul>
        <h2 class="currentMoney">$1,500.00</h2>
      </div>
    </div>
  </div>
</div>

CSS

@-webkit-keyframes myanimation {
  from {
    left: 0%;
  }
  to {
    left: 50%;
  }
}
h1 {
  text-align: center;
  font-family: "PT Sans Caption", sans-serif;
  font-weight: 400;
  font-size: 30px;
  padding: 20px 0;
  color: #777;
}

.checkout-wrap {
  color: #444;
  font-family: "PT Sans Caption", sans-serif;
  margin: 40px auto;
  max-width: 1200px;
  position: relative;
}

ul.checkout-bar {
  margin: 0 20px;
}
ul.checkout-bar li {
  color: #444;
  display: block;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px 14px 80px;
  position: relative;
}
ul.checkout-bar li:before {
  background: #fff;
  border: 2px solid #707070;
  border-radius: 50%;
  color: #707070;
  font-size: 20px;
  font-weight: 700;
  left: 20px;
  line-height: 37px;
  height: 35px;
  position: absolute;
  text-align: center;
  text-shadow: 1px 1px rgba(0, 0, 0, 0.2);
  top: 4px;
  width: 35px;
  z-index: 2;
}
ul.checkout-bar li.active {
  color: #444;
  font-weight: bold;
  padding-left: 10px;
  letter-spacing: 1px;
}
ul.checkout-bar li.active:before {
  background: #fff;
  z-index: 3;
  border-color: #707070;
  color: #707070;
}
ul.checkout-bar li.visited {
  background: #ECECEC;
  color: #444;
  z-index: 3;
  padding-left: 10px;
  letter-spacing: 1px;
}
ul.checkout-bar li.visited:before {
  background: #fff;
  z-index: 3;
  border-color: #707070;
  color: #707070;
}
ul.checkout-bar li:nth-child(1):before {
  content: "$";
}
ul.checkout-bar li:nth-child(2):before {
  content: "$";
}
ul.checkout-bar li:nth-child(3):before {
  content: "$$";
}
ul.checkout-bar li:nth-child(4):before {
  content: "$$";
}
ul.checkout-bar li:nth-child(5):before {
  content: "$$";
}
ul.checkout-bar a {
  color: #444;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  padding-left: 10px;
  letter-spacing: 1px;
}
ul.checkout-bar li.active .progress-value{
  width: 50px;
  height: 25px;
  font-size: 16px;
  font-weight: 600;
  color: #f4bc25;
  line-height: 25px;
  border-radius: 4px;
  position: absolute;
  top: -113px;
  right: -23px;
  letter-spacing: 1px;
}
ul.checkout-bar li.active .t_progress-bar:after{
  content: "\F3C5";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  top: -88px;
  right: -10px;
  font-size: 25px;
  font-weight: 700;
  color: #f4bc25;
}
.finances .checkout-wrap .currentMoney {
  text-align: right;
  padding-top: 100px;
  font-size: 35px;
  color: #f4bc25;
  letter-spacing: 1px;
}
@media all and (min-width: 800px) {
  .checkout-bar li.active:after {
    -webkit-animation: myanimation 3s 0;
    background-size: 35px 35px;
    background-color: #f4bc25;
    content: "";
    height: 28px;
    width: 50%;
    left: 50%;
    position: absolute;
    top: -50px;
    z-index: 0;
  }
  .checkout-wrap {
    margin: 80px auto 0 auto
  }
  ul.checkout-bar {
    background-size: 35px 35px;
    background-color: #fff;
    border-radius: 15px;
    height: 30px;
    margin: 0 auto;
    padding: 0;
    position: absolute;
    width: 100%;
    border: 1px solid #000;
  }
  ul.checkout-bar:before {
    background-size: 35px 35px;
    background-color: #f4bc25;
    border-radius: 15px;
    content: " ";
    height: 28px;
    left: 0;
    position: absolute;
    width: 10%;
  }
  ul.checkout-bar li {
    display: inline-block;
    margin: 50px 0 0;
    padding: 0 0 0 20px;
    text-align: center;
    width: 17%;
  }
  ul.checkout-bar li:before {
    height: 55px;
    width: 55px;
    left: 40%;
    line-height: 55px;
    position: absolute;
    top: -65px;
    z-index: 1;
  }
  ul.checkout-bar li.visited {
    background: none;
  }
  ul.checkout-bar li.visited:after {
    background-size: 35px 35px;
    background-color: #f4bc25;
    content: "";
    height: 28px;
    left: 50%;
    position: absolute;
    top: -50px;
    width: 100%;
    z-index: 1;
  }
}

答案 1 :(得分:0)

如果要动态制作更多的圆圈,则必须使用Javacript制作,但是如果要使其静态(只有5个圆圈),则可以使用:

.row,.progress{ position: relative;width: 100%;}
    .progress-bar{position:relative;background: #f6ba2b;height: 24px; border-radius:36px}
    .progress-bar > .offCircle{
      position:absolute;width:100%;
      height:100%;
      /* background:red; */
    }
    
    .progress:after,
    .progress-bar:before,
    .progress-bar:after,
    .progress-bar > .offCircle:before, 
    .progress-bar > .offCircle:after
    {
    	position:absolute;
    	color: #707070;
    	top: 0;
    	width:33px;
    	height: 33px;
    	background:#fff;
    	margin-top: -7.5px;
    	margin-top: -6.5px;
    	border-radius:36px;
    	border: 2px solid #707070;
    	text-shadow: 0 0 0px black;
    	line-height: 2.2;
    	text-align: center;
    }
    .progress-bar > .offCircle:before{
    	content: '$\A 100';
    	left:1.67%;
    }
    
    .progress-bar > .offCircle:after{
    
    	content: '$\A 500';
    	left:8.33%;
    }
    .progress-bar:before{
    	content: '$$\A 1000';
    	left:16.67%;
    }
    .progress-bar:after{
    	content: '$$\A 2500';
    	left:41.76%;
    }
    .progress:after{
    	content: '$$\A 5000';
    	left:83.33%;
    }
 <div class="row">
        <div class="col-md-6">
          <div class="progress">
            <div class="progress-bar">
                <span class="offCircle"></span>
                <div class="progress-value fa fa-dollar-sign"></div>
            </div>
          </div>
        </div>
      </div>
    
    

要使其具有动画效果,请添加css过渡效果,您必须将特定值计算为%,然后将其传递给使用javascript的进度栏,您可以通过多种方式来实现。