Background size animation not working in IE11 or Ipad

那年仲夏 提交于 2021-02-19 07:29:21

问题


I am trying to create a simple img zoom with CSS3 animation by setting a background image to a div and then resizing that div with the animation. It works fine in FF and Chrome yet in Safari the effect is not smooth.

I've read that adding -webkit-transform: translateZ(0) can help with smoother animations in Safari yet this has no effect.

Can anyone help. Site here http://form-flourish.businesscatalyst.com/form-pilates.htm

Here is my code.
HTML:

<div id="home">
</div>

CSS:

   div#home {
    background: url("../images/home-bg.jpg") no-repeat scroll center center;
    background-size: 100% auto;
    float: left;
    margin: 0 0 20px;
    position: relative;
    width: 100%;
    min-height: 100vh;
    -webkit-animation-name: zoom;
    -webkit-animation-duration: 20s;
    -webkit-animation-delay: 1s;
    -webkit-animation-timing-function: cubic-bezier(0, 0, 1, 1);
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-play-state: running;
    -webkit-animation-direction: alternate;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translate3d(0,0,0);
    /* Standard syntax */
    animation-name: zoom;
    animation-duration: 20s;
    animation-delay: 1s;
    animation-timing-function: cubic-bezier(0, 0, 1, 1);
    animation-iteration-count: infinite;
    animation-play-state: running;
    animation-direction: alternate;
}

    /* Chrome, Safari, Opera */
@-webkit-keyframes zoom {
    0%   {width: 100%; margin-left: 0;}
    100% {width: 150%; margin-left: -25%;}
}
/* Standard syntax */
@keyframes zoom {
    0%   {width: 100%; margin-left: 0;}
    100% {width: 150%; margin-left: -25%;}
}

回答1:


For the first part of your question, Internet Explorer 11's set of animatable CSS properties is the same like they've started in IE 10 with, and background-size is not among those animatable ones.
(Sidekick: Even if W3Schools tells so)

See http://msdn.microsoft.com/en-us/library/ie/dn254934%28v=vs.85%29.aspx for a list of supported properties.




回答2:


I made a simplified test case from your CSS, and it works both IE11 and Safari, though horizontal scroll bar appears. So, I think there should be some other reasons which interrupts animation in your site.

Test case: animating 'width' and 'margin' (simplified from your code) http://asamuzak.jp/test/background_size_animate_test

IE11 (and 10) indeed lacks support for background-size animation, but I made a polyfill for that before. http://asamuzak.jp/html/438 The document is written in Japanese, but in the script source there is a minimum description in English.

Test case 2: animating 'background-size' with IE polyfill http://asamuzak.jp/test/background_size_animate_test2



来源:https://stackoverflow.com/questions/25116982/background-size-animation-not-working-in-ie11-or-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!