簡體   English   中英

如何制作動畫多色進度條?

[英]How To Make an Animated Multi-Color Progress Bar?

我是新來的,所以如果我不清楚的話很抱歉。 我正在嘗試構建多色進度條,以在頁面加載時進行動畫處理。 我發現了與我正在尋找的示例類似的示例,但是javascript / jquery卻給我帶來了問題。 我在那方面不熟練。

示例1: https//codepen.io/tamak/pen/hzEer

該鏈接顯示了我希望頁面出現時欄如何逐漸擴展並以一定百分比停止。

jQuery(document).ready(function(){
  jQuery('.skillbar').each(function(){
    jQuery(this).find('.skillbar-bar').animate({
      width:jQuery(this).attr('data-percent')
    },6000);
  });
});

示例2: http//www.cssflow.com/snippets/animated-progress-bar/demo

非常接近我想要的內容,但是我希望進度條在沒有按鈕的情況下也能正常運行。 從紅色到綠色的色彩本身就是我想要達到的目標。

提前致謝! 我知道可能要求很多,但是我希望有人願意嘗試一下。

也許會有所幫助: 漸變顏色的Bootstrap進度條在有效寬度上成比例顯示

至於移動進度條,您到底要如何更改它? 您不需要按鈕即可執行操作,但是需要發生一些事情。 您能詳細解釋一下嗎?

您可以根據時間間隔設置按鈕的單擊事件。

 $(document).ready(function(){ var CurrentProgress = '75%'; setTimeout(function(){ $(".label").each(function() { if($(this).html()==CurrentProgress){ $(this).click(); } }) },1000) }) 
 .container { margin: 80px auto; width: 640px; text-align: center; } .container .progress { margin: 0 auto; width: 400px; } .progress { padding: 4px; background: rgba(0, 0, 0, 0.25); border-radius: 6px; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px rgba(255, 255, 255, 0.08); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px rgba(255, 255, 255, 0.08); } .progress-bar { position: relative; height: 16px; border-radius: 4px; -webkit-transition: 0.4s linear; -moz-transition: 0.4s linear; -o-transition: 0.4s linear; transition: 0.4s linear; -webkit-transition-property: width, background-color; -moz-transition-property: width, background-color; -o-transition-property: width, background-color; transition-property: width, background-color; -webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.25), inset 0 1px rgba(255, 255, 255, 0.1); box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.25), inset 0 1px rgba(255, 255, 255, 0.1); } .progress-bar:before, .progress-bar:after { content: ''; position: absolute; top: 0; left: 0; right: 0; } .progress-bar:before { bottom: 0; background: url("../img/stripes.png") 0 0 repeat; border-radius: 4px 4px 0 0; } .progress-bar:after { z-index: 2; bottom: 45%; border-radius: 4px; background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05)); background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05)); background-image: -o-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05)); background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05)); } #five:checked ~ .progress > .progress-bar { width: 5%; background-color: #f63a0f; } #twentyfive:checked ~ .progress > .progress-bar { width: 25%; background-color: #f27011; } #fifty:checked ~ .progress > .progress-bar { width: 50%; background-color: #f2b01e; } #seventyfive:checked ~ .progress > .progress-bar { width: 75%; background-color: #f2d31b; } #onehundred:checked ~ .progress > .progress-bar { width: 100%; background-color: #86e01e; } .radio { display: none; } .label { display: none; margin: 0 5px 20px; padding: 3px 8px; color: #aaa; text-shadow: 0 1px black; border-radius: 3px; cursor: pointer; } .radio:checked + .label { color: white; background: rgba(0, 0, 0, 0.25); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <section class="container"> <input type="radio" class="radio" name="progress" value="five" id="five" checked> <label for="five" class="label">5%</label> <input type="radio" class="radio" name="progress" value="twentyfive" id="twentyfive"> <label for="twentyfive" class="label">25%</label> <input type="radio" class="radio" name="progress" value="fifty" id="fifty"> <label for="fifty" class="label">50%</label> <input type="radio" class="radio" name="progress" value="seventyfive" id="seventyfive"> <label for="seventyfive" class="label">75%</label> <input type="radio" class="radio" name="progress" value="onehundred" id="onehundred"> <label for="onehundred" class="label">100%</label> <div class="progress"> <div class="progress-bar"></div> </div> </section> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM