【问题标题】:Loading animation doesn't work in IE加载动画在 IE 中不起作用
【发布时间】:2017-06-06 15:43:19
【问题描述】:

我想在我的页面完全加载时显示加载 div。 CSS 旋转功能在 Google Chrome 上完美运行,但在 IE 上无法运行。

我的CSS代码和html代码如下。

/*Transparent*/
.tr_loading {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0,0,0,.5);
}
.tr_loading-wheel {
    width: 20px;
    height: 20px;
    margin-top: -40px;
    margin-left: -40px;
    
    position: absolute;
    top: 50%;
    left: 50%;
    
    border-width: 30px;
    border-radius: 50%;
    -webkit-animation: spin 1s linear infinite;
    -o-animation: spin 1s linear infinite;
    animation:spin 1s linear infinite;
}
.style-2 .tr_loading-wheel {
    border-style: double;
    border-color: #ccc transparent;
}
@-webkit-keyframes spin {
    0% {
        -webkit-transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(-360deg);
    }
}
<div class="tr_loading style-2">
    <div class="tr_loading-wheel"></div>
</div>

【问题讨论】:

    标签: html css internet-explorer css-animations loading


    【解决方案1】:

    以下是供应商前缀代码示例,并非所有浏览器都支持。

    @-webkit-keyframes spin {
      0% {
        -webkit-transform: rotate(0deg);
      }
      100% {
        -webkit-transform: rotate(-360deg);
      }
    }
    

    使用标准变体,即:

    @keyframes spin {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(-360deg);
      }
    }
    

    MDN 上查看@keyframes 的详细文档。

    工作演示:

    /*Transparent*/
    .tr_loading {
      width: 100%;
      height: 100%;
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background-color: rgba(0,0,0,.5);
    }
    .tr_loading-wheel {
      width: 20px;
      height: 20px;
      margin-top: -40px;
      margin-left: -40px;
    
      position: absolute;
      top: 50%;
      left: 50%;
    
      border-width: 30px;
      border-radius: 50%;
      -webkit-animation: spin 1s linear infinite;
      -o-animation: spin 1s linear infinite;
      animation:spin 1s linear infinite;
    }
    .style-2 .tr_loading-wheel {
      border-style: double;
      border-color: #ccc transparent;
    }
    @keyframes spin {
      0% {
          transform: rotate(0deg);
      }
      100% {
          transform: rotate(-360deg);
      }
    }
    <div class="tr_loading style-2">
        <div class="tr_loading-wheel"></div>
    </div>

    【讨论】:

      猜你喜欢
      • 2016-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多