gpt4 book ai didi

javascript - background-position-x + 动画从右到左 + IE

转载 作者:行者123 更新时间:2023-11-28 03:06:48 26 4
gpt4 key购买 nike

IE 中的动画问题。
我正在尝试连续平稳地左右移动背景。该代码适用于除 IE 之外的所有浏览器。
问题:从左向右移动时显示问题。
请找到fiddle 我已经添加了。

function call1(){
$('.container').animate({ 'background-position-x': '100%' }, 2000);
}

function animateBg(){
call1();
setTimeout(function(){
$('.container').animate({ 'background-position-x': '0%' }, 2000,function(){
animateBg();
});
console.log("hii");
});
}

animateBg();
.main{height:100%;}
.container{
background:url('http://www.smartbygep.com/sites/default/files/SBG-home-page-banner.jpg')no-repeat top center;
background-position-x:0%;
color:#333; /*-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
-moz-transform: scale(1,1);
-webkit-transform: scale(1,1);
transform: scale(1,1);*/
background-size:120% 100%;
background-color:#ccc;
height:300px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main">
<div class="container">
Sample text
</div>
</div>

最佳答案

你必须使用

animate({ backgroundPosition: '0%' }

JSFiddle

关于javascript - background-position-x + 动画从右到左 + IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32334625/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com