I am animating an element across the screen, but strange things happen in IE11. I am in development, so I can not share live code. But I created a violin to reproduce the problem.
Basically, when I use aka vw viewport width with transform:translateX(); inside @keyframes for use in animation, IE11 does not reflect the width of the viewport in the animation.
So, the Fiddle I created takes an element located in the center of the viewport :
- launches it at the left edge of the screen with a half element appears
- moves to the center of the viewing area, pauses
- and then it moves to the right edge of the viewport, with half the item exiting the screen.
Fiddle: https://jsfiddle.net/Bushwazi/7xe0wy8z/4/
- On the website I'm working on, IE11 animates the element as if the page was 10 times wider
- In the violin, the animation works in reverse order and never reaches the edge of the page.
So, in both cases, IE11 does not use the correct width for vw inside the CSS animation.
HTML:
<article> <p>IE11 weirdness when transforming vw inside keyframes</p> <strong><span>BLOCK</span></strong> </article>
CSS
* { margin: 0; padding: 0; } @-webkit-keyframes movee { 0% { -webkit-transform: translateX(-50vw); transform: translateX(-50vw) } 10% { -webkit-transform: translateX(-50vw); transform: translateX(-50vw) } 40% { -webkit-transform: translateX(0vw); transform: translateX(0vw) } 60% { -webkit-transform: translateX(0vw); transform: translateX(0vw) } 90% { -webkit-transform: translateX(50vw); transform: translateX(50vw) } 100% { -webkit-transform: translateX(50vw); transform: translateX(50vw) } } @keyframes movee { 0% { -webkit-transform: translateX(-50vw); transform: translateX(-50vw) } 10% { -webkit-transform: translateX(-50vw); transform: translateX(-50vw) } 40% { -webkit-transform: translateX(0vw); transform: translateX(0vw) } 60% { -webkit-transform: translateX(0vw); transform: translateX(0vw) } 90% { -webkit-transform: translateX(50vw); transform: translateX(50vw) } 100% { -webkit-transform: translateX(50vw); transform: translateX(50vw) } } body { background-color: #eee; background-image: -webkit-linear-gradient(left, black 50%, transparent 50.01%); background-image: linear-gradient(90deg, black 50%, transparent 50.01%); background-size: 20% 100%; background-position: 0 0; font-family: sans-serif; height: 100vh; } article { position: relative; height: 100%; width: 100%; display: block; } p { width: 100%; background: #FFF; text-align: center; padding: 1em 0; } strong { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; height: 100px; width: 100px; background: red; border: blue solid 3px; position: absolute; top: 50%; left: 50%; box-sizing: border-box; text-align: center; margin: -50px 0 0 -50px; -webkit-animation: movee 5.0s linear infinite 0.0s; animation: movee 5.0s linear infinite 0.0s; }
source share