【问题标题】:animtion not working on page redirection in safari and IE 11动画在 Safari 和 IE 11 中的页面重定向上不起作用
【发布时间】:2020-04-13 01:20:12
【问题描述】:

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

【问题讨论】:

  • 我不知道IE,但是在safari上,在页面加载过程中,所有的动画都被浏览器本身屏蔽了。
  • 我建议你展示你的示例代码。这样我们就可以尝试查看您在代码中实际在做什么。我们可以用它来测试IE和其他浏览器来查看结果。

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


【解决方案1】:

试试这个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 浏览器中的输出:

【讨论】:

  • 对不起,我想在从 page1 重定向 page2 的过程中显示一个加载器。从第一页点击表单提交时,将重定向第二页。
  • 然后您可以尝试将此代码放在您按下提交按钮的页面上。所以加载器会在用户点击提交按钮后显示,当新页面加载时它会消失。无法在重定向之间显示加载程序。
猜你喜欢
  • 1970-01-01
  • 2022-10-23
  • 2018-12-11
  • 2011-04-13
  • 1970-01-01
  • 1970-01-01
  • 2018-02-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多