css - 动画不适用于 Safari 和 IE 11 中的页面重定向

标签 css browser safari css-animations internet-explorer-11

我试图在页面重定向时显示加载器动画,重定向是通过表单提交启动的。但是动画在 Safari 和 IE 中不起作用。尝试过 CSS 关键帧动画、GIF 和视频都不起作用。 GIF 和视频不播放,它只是显示静态图像。在 Safari 和 IE11 中面临这个问题。

最佳答案

试试这个 W3Schools example .它适用于 IE 11 和其他浏览器。

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Center the loader */
#loader {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 150px;
  height: 150px;
  margin: -75px 0 0 -75px;
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid #3498db;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 2s linear infinite;
}

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

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

/* Add animation to "page content" */
.animate-bottom {
  position: relative;
  -webkit-animation-name: animatebottom;
  -webkit-animation-duration: 1s;
  animation-name: animatebottom;
  animation-duration: 1s
}

@-webkit-keyframes animatebottom {
  from { bottom:-100px; opacity:0 } 
  to { bottom:0px; opacity:1 }
}

@keyframes animatebottom { 
  from{ bottom:-100px; opacity:0 } 
  to{ bottom:0; opacity:1 }
}

#myDiv {
  display: none;
  text-align: center;
}
</style>
</head>
<body onload="myFunction()" style="margin:0;">

<div id="loader"></div>

<div style="display:none;" id="myDiv" class="animate-bottom">
  <h2>Tada!</h2>
  <p>Some text in my newly loaded page..</p>
</div>

<script>
var myVar;

function myFunction() {
  myVar = setTimeout(showPage, 3000);
}

function showPage() {
  document.getElementById("loader").style.display = "none";
  document.getElementById("myDiv").style.display = "block";
}
</script>

</body>
</html>

在 IE 11 浏览器中的输出:

enter image description here

关于css - 动画不适用于 Safari 和 IE 11 中的页面重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59426746/

相关文章:

LI 上的 CSS 箭头

所有浏览器中的 JavaScript 和 jQuery 滚动问题

c# - 仅使用类项从网页获取特定数据

javascript - Safari 和文件上传表单不起作用

jquery - 在 iPhone 上的 Web 应用程序中维护 PHP session

html - IE 特定 html 和 CSS 标签/属性列表

javascript - Ace响应模板jqGrid搜索框ui问题

javascript - 使用 CSS3 rotateY 的卡片翻转效果,但根据按钮按下有多个面孔?

html - 在列表标签​​之间放置 DIV 标签是否有效?

java - 如何停止在每次请求时向服务器发送 cookie