[英]How to make a css keyframe step animation responsive?
Can't seem to find a solution for css keyframes animations, if I need it to be responsive ? 如果需要响应,似乎似乎找不到CSS关键帧动画的解决方案? http://jsbin.com/muyeguba/9
http://jsbin.com/muyeguba/9
Using *step animation. 使用* step动画。 Which implies having a correct width that can be divided by the number of steps I guess to generate the animation.
这意味着具有正确的宽度,该宽度可以除以我猜生成动画的步骤数。
I tried to change the width with js but the animation breaks, and starts sliding instead (what I mean, is that the step animation stops and new frames are basically coming from right to left). 我试图用js更改宽度,但是动画中断了,而是开始滑动(我的意思是,步进动画停止了,新的帧基本上从右到左)。
$(window).on('resize', function(){ $(window).on('resize',function(){
if ( window.innerWidth >= maxSz ) {
return;
};
originalW = 18490; //this is the original stripe width
originalH = 383;
ratio = containerFooWidth / maxSz;
newSize = originalW/ratio + "px" + " " + originalH/ratio + "px";
$(".my-sprite").css("background-size", newSize);
}); });
I wonder if there's someone experienced ? 我想知道是否有人经验丰富? Otherwise I can imagine that the other way around this would be using breakpoints.
否则,我可以想象解决此问题的另一种方法是使用断点。 and have the specific animation for each container size.
并针对每个容器尺寸制作特定的动画。
Begin with responsive size on the element: 从元素的响应大小开始:
.animate {
width:100%;
height: 0px;
padding-bottom: 75%;
}
and since you have 43 steps, set the background animation accordingly 并且由于您有43个步骤,因此可以相应地设置背景动画
@keyframes play {
from { background-position: 0% }
to { background-position: 4300%; }
}
and also the background size 还有背景尺寸
.animate {
background-size: 4300%;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.