css - CSS 动画在 safari 上不起作用,但在 chrome 上很好
问题描述
我设计了一个包含许多动画的页面,并且在 chrome 和 firefox 等浏览器上都运行良好,但是当在 safari (MAC) 和 safari(Windows) 上打开相同的内容时,它不会显示动画。我没有得到,确切的问题是什么。
我添加了包含三个动画animation1、animation2 和animation3 的html。我只添加了animation2 css。其余动画几乎相同。
这是HTML: -
$(document).on("scroll", function () {
if (isScrolledIntoView1($elem1, $window1)) {
$elem1.addClass("animate1")
}
});
$(document).on("scroll", function () {
if (isScrolledIntoView($elem, $window)) {
$elem.addClass("animate2")
}
});
$(document).on("scroll", function () {
if (isScrolledIntoView2($elem2, $window2)) {
$elem2.addClass("animate3")
}
});
var $window = $(window);
var $elem = $(".animation2")
function isScrolledIntoView($elem, $window) {
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
var $window1 = $(window);
var $elem1 = $(".animation1")
function isScrolledIntoView1($elem1, $window1) {
var docViewTop1 = $window1.scrollTop();
var docViewBottom1 = docViewTop1 + $window1.height();
var elemTop1 = $elem1.offset().top;
var elemBottom1 = elemTop1 + $elem1.height();
return ((elemBottom1 <= docViewBottom1) && (elemTop1 >= docViewTop1));
}
var $window2 = $(window);
var $elem2 = $(".animation3")
function isScrolledIntoView2($elem2, $window2) {
var docViewTop2 = $window2.scrollTop();
var docViewBottom2 = docViewTop2 + $window2.height();
var elemTop2 = $elem2.offset().top;
var elemBottom2 = elemTop2 + $elem2.height();
return ((elemBottom2 <= docViewBottom2) && (elemTop2 >= docViewTop2));
}
.animation2.animate2 {
animation-name: pulse2;
animation-duration: 2s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
animation-delay: 0s;
-webkit-animation-name: pulse2;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1;
-webkit-animation-fill-mode: forwards;
-webkit-animation-delay: 0s;
}
@keyframes pulse2 {
0% {
position: relative;
top: -500px;
left: 100px;
background-color: #94D6E2;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 750px;
height: 300px;
margin-top: 150px;
z-index: -1;
}
100% {
position: relative;
top: -600px;
left: 100px;
background-color: #94D6E2;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 850px;
height: 400px;
margin-top: 150px;
z-index: -1;
}
}
@-webkit-keyframes pulse2 {
0% {
position: relative;
top: -500px;
left: 100px;
background-color: #94D6E2;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 750px;
height: 300px;
margin-top: 150px;
z-index: -1;
}
100% {
position: relative;
top: -600px;
left: 100px;
background-color: #94D6E2;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 850px;
height: 400px;
margin-top: 150px;
z-index: -1;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="about-slide1">
<div class="animation3" style="background-image: url('img/01.png');"></div>
<div class="animation1">
<div class=" about-slide1-position">
<h3 class="pt-4 about-slide1-title">Custom</h3>
<hr class="about-slide1-hr">
<h5 class="px-5" >Top culinary chefs from across the country have prepared a highly delectable keto menu, comprising of dishes such as Hyderabadi Biryani, Butter Chicken, Thin Crust Pizza, Pasta and Chocolate Mousse amongst others.</h5>
</div>
<div class="tech-slideshow">
<div class="mover-1" style="background-image: url(img/04.png);background-size: cover;"></div>
</div>
</div>
<div class="animation2"></div>
</div>
<div class="animation2"></div>
</div>
解决方案
推荐阅读
- java - 在android中使用google map api时无法更新位置
- javascript - Javascript ISReachable 不起作用。说require没有定义
- php - 如何将用户 ID 保存在 laravel 中特定用户使用软删除删除的记录中
- python - 如何读取文件夹中的所有图像?
- bash - Bash 解析器在命令行中以什么顺序转义字符和拆分单词/标记?
- swift - 为具有失败响应的字典数组实现 Codable
- javascript - Retyped.chartist 用法不清楚。如何创建基本折线图?
- android - 从 Firestore 获取数据后,方法总是返回 null
- java - 内存分配 Java 异常
- php - 将数据从一个表复制到另一个没有 ID