I am currently facing a probably very basic issue with Safari and CSS3 transformations. I am trying to align a grey circle in the center of the screen and then to animate it.
My CSS code seems to work perfectly with any other browser but the circle doesn't align well in Safari. However if I move out the animation everything goes fine. This is the reason why I guess something is wrong with my code :
#loading_container{
width:100%; height:100%;
background-color: #26262B;
position: absolute;
}
#loading_container>img{
position: absolute;
top: 50%;
left: 50%;
width:20%; height:auto;
min-width: 200px;
-ms-transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
-o-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
-webkit-animation: rotate 5s infinite;
animation: rotate 5s infinite;
}
#-webkit-keyframes rotate {
from {-webkit-transform: translate(-50%,-50%) rotate(0deg);transform: translate(-50%,-50%) rotate(0deg);}
to {-webkit-transform: translate(-50%,-50%) rotate(-360deg);transform: translate(-50%,-50%) rotate(-360deg);}
}
#keyframes rotate {
from {-webkit-transform: translate(-50%,-50%) rotate(0deg);transform: translate(-50%,-50%) rotate(0deg);}
to {-webkit-transform: translate(-50%,-50%) rotate(-360deg);transform: translate(-50%,-50%) rotate(-360deg);}
}
<div id="loading_container">
<img src="http://s32.postimg.org/721vouc3p/loading_icon.png" alt="Loading..."/>
</div>
The weirdest thing is that if I move to another desktop on my mac (I mean if I scroll to the left or right) and then come back to the main one with Safari opened, the circle aligns perfectly as you can see on these two pictures :
This is the result when the page has been loaded...
And this is when I move back to the main desktop without having done anything else
I know there are a plenty of other ways to do it but I would only understand what can go wrong here. Does someone have an idea how to solve this problem ?
Thank you for your help !
I stumbled into an issue with Safari on iOS yesterday so I thought I could share my solution with you.
When applying a translate(-50%, -50%) together with rotate, on iOS the translate property was ignored. transform-origin didn't help.
After trying all possible variant, I found the one that did work:
$size: 50px;
transform: translate(-$size/2, -$size/2) rotate(0deg);
So the absolute values (instead of percentages) for translate solved the problem. Hope this might help you, too!
Related
I have a simple GIF image that I am applying a keyframe animation to (to make it spin infinitely), and for some reason, if I hover over links elsewhere on the page, they randomly jump up or down by a pixel or two.
When I remove the DOM element that has the animation on it (the image) the jumping does not occur, leading me to believe it is somehow caused by the CSS animation somehow. This ONLY happens in Chrome, even the most recent update of Chrome.
I have read all other related questions on here and nothing has resolved it yet, it is NOT the -webkit-backface-visibility fix needed here.
Example CSS:
#mixin spin {
-webkit-animation: spin360 1.26s infinite linear;
animation: spin360 1.26s infinite linear;
}
#-webkit-keyframes spin360 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes spin360 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.animated-image {
position: absolute;
#include spin;
}
Example DOM:
<h3 class="header">
Heading title
</h3>
<div class="animated-image"><img src="../img/loader.gif"></div>
Working example: http://codepen.io/caseytrombley/pen/YWYqRQ
I think the problem is in chrome the img it isn't vertical and horizontal centered.
I suggest you use flexbox to centered and must be fixed
Other way is use the img like background image and put
background-position: center center;
background-size: contain;
but I can imagine it's an animated gif, in that case must be fixed with flex
I have an SVG element with a circle inside it. The SVG is being rotated infinitely using a keyframe animation:
#keyframes rotate {
0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
svg{
width: 500px;
height: 500px;
display: block;
animation: rotate 2.9s linear infinite;
transform-origin: center;
}
My issue is that, on Internet Explorer 11, the rotation seems to wobble slightly as it is rotating (all other browsers behave as expected). Try focusing on the top or left edges of the black box.
Is there any way I can avoid this?
Here's a fiddle with the test scenario.
And below is a gif that showcases it as well:
In case anyone is wondering, here's how I managed to work around this: The SVG's transform-origin should be set to the circle's radius (in this case 250px) in all dimensions(x, y and z).
svg{
/* other styles go here */
transform-origin: 250px 250px 250px;
}
img{
transition-duration: 5s;
transform: scale(1.0);
transform-origin: 50% 50%;
}
&:hover{
img{
transform: scale(1.2);
transform-origin: 50% 50%;
}
}
This is the code I have used for ken burn effect in images, it works very fine in ff, chrome and safari. But I don't know what is the problem in ie 11.
Can you help me with it.
I encountered the same issue and fixed my problem by adding a small to rotation to the image.
transform: scale(1.5) rotate(0.1deg);
I came across an article offering this solution for a bug in firefox but it also works for the internet explorer like a charm.
On Firefox, when I mouseover the element the element runs the css3 animation and on mouse out the animation is reverted:
http://jsbin.com/bapen/2/watch
With the same code base, with all the webkit vendor prefixes, I don't have the same effect. So, when mouseover the element rotates but on mouseout it doesn't rotate the other way back to the initial state.
Firefox behaves in a nicer way and I guess, this is not supported on Chrome ?
The reason I've mentioned "transition of animation", it's that when testing, the property transition: all 0.45s, is what makes this work like it does on FF.
Not sure if someone more experienced can give some hints ? Thanks!
After playing with it for a while, it seems that Chrome doesn't automatically reverse keyframe animations. I don't know if there's some option to enable that or anything, but if you specify the transforms directly in the :hover css rule, it seems to work consistently across Chrome and Firefox, i.e. change this:
#keyframes rotateMe {
0% {
-webkit-transform-origin: center center;
-ms-transform-origin: center center;
transform-origin: center center;
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform-origin: center center;
-ms-transform-origin: center center;
transform-origin: center center;
-webkit-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#-webkit-keyframes rotateMe {
. . .
}
.rotateMe:hover {
animation-name: rotateMe;
-webkit-animation-name: rotateMe;
}
to this:
.rotateMe:hover {
-webkit-transform-origin: center center;
-ms-transform-origin: center center;
transform-origin: center center;
-webkit-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
Then the desired reversal effect seems to work, at least it did for me. In this case it's also less code, but obviously if your real goal is something requires keyframe animations, this solution won't work.
Also I should note, for clarity, that in the original Chrome did return to the initial state (which happened to look just like the final state), it's just that it did it immediately, rather than going backwards through the animation. You can verify this by ending at a rotation that's not a multiple of 90 degrees. Similarly if you change the background color in the :hover rule you'll see that it smoothly transitions in both directions.
I have a CSS3 Animation for an indeterminate progress bar. In the animation I have a gradient oscillating back and forth along the progress bar. I would like to flip the image of gradient horizonally as it travels back to the left side of the progress bar. Basically the gradient always fades out the opposite direction the image is moving. Unfortunately I can't figure out a way for the image to flip horizontally BEFORE it starts moving back towards the left and am getting some odd transformations of the image as it flips.
I have created a JSFiddle to show how it looks right now.
http://jsfiddle.net/MtWzL/
Here is the CSS I'm currently using for the animation:
#-webkit-keyframes loader {
0% {
-webkit-transform: scaleX(1);
-webkit-transform: translateX(-100px);
-webkit-transform-origin:left;
}
50% {
-webkit-transform: translateX(300px);
}
100% {
-webkit-transform: translateX(-100px);
-webkit-transform: scaleX(-1);
}
}
#keyframes loader {
0% {
transform: scaleX(1);
transform: translateX(-100px);
transform-origin:left;
}
50% {
transform: translateX(300px);
}
100% {
transform: translateX(-100px);
transform: scaleX(-1);
}
}
.slider
{
animation: loader 2.5s infinite linear;
-webkit-animation: loader 2.5s infinite linear; /* Safari and Chrome */
background: url('http://s23.postimg.org/mglkwgxuv/indeterminate_bg.png') no-repeat;
border-radius: 10px;
height: 10px;
position: relative;
width: 100px;
z-index: 999;
opacity: .6;
}
.container {
background: -webkit-linear-gradient(#00c3ff,#0071bc);
background: linear-gradient(#00c3ff,#0071bc);
border-radius: 3px;
height: 10px;
overflow: hidden;
width: 300px;
}
.background {
background: rgba(0,0,0,0.7);
border-radius: 3px;
display: inline-block;
padding: 10px;
}
There are 2 issues that need to be fixed
first of all, this
-webkit-transform: scaleX(1);
-webkit-transform: translateX(-100px);
won't work as you expect; the second property over-rides the first one, as you can not set 2 different values for a property in separate lines.
the correct syntax would be
-webkit-transform: translateX(-100px) scaleX(1);
And second, if you want a sudden change in some value, you need to set it from a keyframe to another keyframe close enough to the first one.
So, the solution would be
#-webkit-keyframes loader {
0% { -webkit-transform: translateX(-100px) scaleX(1); }
50% { -webkit-transform: translateX(300px) scaleX(1); }
51% { -webkit-transform: translateX(300px) scaleX(-1); }
100% { -webkit-transform: translateX(-100px) scaleX(-1); }
}
corrected fiddle
I have corrected only the webkit transforms, but the same concept applies to the rest.
I was watching for your problem since you put it here, but I guess its some kind of bug we won't solve or maybe I just dont understand why it is working like that.
Since I had no clue how to solve it I manage to do example for you with alternative solution
EXAMPLE
As you can see I modified your jsfiddle, simple words, created another slide loader .sliderBack that goes backwards. Hope it will helps you somehow. Peace :)