Gmail进度条css代码问题

时间:2015-04-28 20:42:58

标签: javascript html css

我正在尝试使用Gmail正在使用的进度条,我在此网页中找到了一些代码:http://cssdeck.com/labs/new-gmail-styled-progress-bar,不幸的是,进度条仅在Internet Explorer中显示,但在Google Chrome中不显示和Mozilla Firefox。我尝试使用古老版本的谷歌浏览器(版本41),它的工作原理。如果有人可以帮助我,我会非常感激。

CSS:

.loader_box {
    text-align: center;
    width: 320px;
    border: 1px solid #999;
    padding: 1px;
    height: 8px;
    margin-right: auto;
    margin-left: auto;
}
.loader {
    width: 0;
    height: 100%;
    background-color: #6188F5;
    background-repeat: repeat-x;
    background-position: 0 0;
    /*background-size*/
    -webkit-background-size: 16px 8px;
    -moz-background-size: 16px 8px;
    -o-background-size: 16px 8px;
    background-size: 16px 8px;
    background-image: -webkit-linear-gradient(315deg,transparent,transparent 33%,rgba(0, 0, 0, 0.12) 33%,rgba(0, 0, 0, 0.12) 66%,transparent 66%,transparent);
    background-image: -moz-linear-gradient(315deg,transparent,transparent 33%,rgba(0, 0, 0, 0.12) 33%,rgba(0, 0, 0, 0.12) 66%,transparent 66%,transparent);
    background-image: -o-linear-gradient(315deg,transparent,transparent 33%,rgba(0, 0, 0, 0.12) 33%,rgba(0, 0, 0, 0.12) 66%,transparent 66%,transparent);
    background-image: linear-gradient(315deg,transparent,transparent 33%,rgba(0, 0, 0, 0.12) 33%,rgba(0, 0, 0, 0.12) 66%,transparent 66%,transparent);
    /*animation*/
    -webkit-animation: load 5s linear 0 infinite;
    -moz-animation: load 5s linear 0 infinite;
    -ms-animation: load 5s linear 0 infinite;
    -o-animation: load 5s linear 0 infinite;
    animation: load 5s linear 0 infinite;
}
/* Then animate the stuff */
@-webkit-keyframes load { 
    0% { width: 0% ;
        background-position:0 0;}
    100% { width: 100%;
            background-position:-40px 0;
            }
}
@-ms-keyframes load { 
   0% { width: 0% ;
        background-position:0 0;}
    100% { width: 100%;
            background-position:-40px 0;
            }
}
@-o-keyframes load { 
    0% { width: 0% ;
        background-position:0 0;}
    100% { width: 100%;
            background-position:-40px 0;
            }
}
@keyframes load { 
  0% { width: 0% ;
        background-position:0 0;}
    100% { width: 100%;
            background-position:-40px 0;
            }
}

HTML:

<div class="loader_box">
    <div class="loader"></div>
</div>

JavaScript:

<script>
var displayLoaderCount =     0;

function printMsg(message, clearQueue){
    displayLoaderCount--;

    if (!message || displayLoaderCount < 0){
        message = "An error occured"; 
        displayLoaderCount=0;
    }

    if (clearQueue){ 
        displayLoaderCount=0;
    }

    if (displayLoaderCount==0){
      $(".loader_box").hide();

      $("input").prop("disabled", false);
      $("button").prop("disabled", false);
      $("select").prop("disabled", false);
      $("div").prop("disabled", false);
      $(".message-section").html(message).fadeIn("slow", function(){}).delay(5000).fadeOut("slow",function() {});
      $(".credits-section").hide().delay(5700).fadeIn("slow",function() {});   
    }else{
      $(".message-section").html(message).fadeIn("slow", function(){});
      $(".credits-section").hide();
    }
}


function displayLoading(){
    $(".loader_box").show();
    displayLoaderCount++;
    $("input").prop("disabled", true);
    $("button").prop("disabled", true);
    $("select").prop("disabled", true);
    $("div").prop("disabled", true);
}
</script>

1 个答案:

答案 0 :(得分:5)

我相信我找到了一种让它发挥作用的方法;虽然我不确定为什么!

我所做的就是从.loader的-webkit-animation中删除0。 (css部分第37行),即:

旧版本: -webkit-animation: load 5s linear 0 infinite;

新版本: -webkit-animation: load 5s linear infinite;

http://cssdeck.com/labs/cufgituy

如果有人有兴趣,可在此处提供W3C标准:

http://www.w3.org/TR/css3-animations/#animation