CSS3 animation: Not loading in Safari - css

the following animation doesn't even load in Safari browser (but works nicely in Chrome, Mozilla, IE, Opera)
http://codepen.io/anon/pen/utdIK
Any idea how to fix it? This problem looks similar, but it didn't fit to my problem.
CSS3 animation not working in safari
HTML:
<div id="spinner-2">
<div class="slices bar">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div class="maskWheel"></div>
</div>
CSS:
#spinner-2 {
width: 45px;
height: 45px;
-webkit-border-radius: 100px;
-moz-border-radius: 50%;
border-radius: 50%;
overflow: hidden;
margin: 0 auto;
-webkit-animation: spin .8s infinite steps(8);
-moz-animation: spin .8s infinite steps(8);
-ms-animation: spin .8s infinite steps(8);
-o-animation: spin .8s infinite steps(8);
animation: spin .8s infinite steps(8);
}
.slices {
width: 45px;
height: 45px;
position: relative;
transform-origin: right bottom;
}
.slices.bar div {
width: 100%;
height: 100%;
position: absolute;
-webkit-border-radius: 100px;
-moz-border-radius: 50%;
border-radius: 50%;
background: -webkit-linear-gradient(45deg, #cdcdcd 43%, transparent 43%) 0 0;
background: -moz-linear-gradient(45deg, #cdcdcd 43%, transparent 43%) 0 0;
background: -o-linear-gradient(45deg, #cdcdcd 43%, transparent 43%) 0 0;
background: linear-gradient(45deg, #cdcdcd 43%, transparent 43%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%}
#-webkit-keyframes spin {
to {
transform: rotate(1turn);
}
}#-moz-keyframes spin {
to {
transform: rotate(1turn);
}
}#-ms-keyframes spin {
to {
transform: rotate(1turn);
}
}#keyframes spin {
to {
transform: rotate(1turn);
}
}.slices.bar div:nth-child(1) {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
.slices.bar div:nth-child(2) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.slices.bar div:nth-child(3) {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.slices.bar div:nth-child(4) {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.slices.bar div:nth-child(5) {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.slices.bar div:nth-child(6) {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
.slices.bar div:nth-child(7) {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.slices.bar div:nth-child(8) {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
.slices.bar div:nth-child(3) {
background: linear-gradient(45deg, #ed3000 43%, transparent 43%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%}

As Dan stated in his answer, the -webkit- prefix was missing.
One issue for Safari 5 is that shortend properties will not be interpreted by the browser.
You need to specify each single animation property in full.
-webkit-animation-name: spin;
-webkit-animation-duration: 8s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: steps(8);
-moz-animation-name: spin;
-moz-animation-duration: 8s;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: steps(8);
-ms-animation-name: spin;
-ms-animation-duration: 8s;
-ms-animation-iteration-count: infinite;
-ms-animation-timing-function: steps(8);
-o-animation-name: spin;
-o-animation-duration: 8s;
-o-animation-iteration-count: infinite;
-o-animation-timing-function: steps(8);
animation-name: spin;
animation-duration: 8s;
animation-iteration-count: infinite;
animation-timing-function: steps(8);
If still does not work you can try to remove the to and add the percentage and change the 1turn unit and add the default one in degrees.
#-webkit-keyframes spin {
100% {
transform: rotate(360deg);
}
}#-moz-keyframes spin {
100% {
transform: rotate(360deg);
}
}#-ms-keyframes spin {
100% {
transform: rotate(360deg);
}
}#keyframes spin {
100% {
transform: rotate(360deg);
}
DEMO http://jsfiddle.net/a_incarnati/q0v1wgc8/2/ with no 'to' and '1turn'
DEMO http://jsfiddle.net/a_incarnati/q0v1wgc8/3/
Let me know if it works in Safari 5.0.5

The -webkit- prefix was missing from your webkit specific keyframe.
#-webkit-keyframes spin {
to {
-webkit-transform: rotate(1turn);
}
Here's an updated Codepen
Tested in Safari 7.

I would just like to add that the element should be display:block type in Safari (display: inline works in chrome only ...)

Related

Combining multiple CSS animations into one

I'm pretty new to programming and CSS animations so please excuse me if I'm using the wrong terms :-)
I have two animations on one element. I have an image of a man on a scooter that slides into the homepage (once) when it's loaded and then on hover it bounces (infinite).
Below is my code:
HTML:
<section>
<!--Animation and Welcome Heading-->
<div class="welcome-container">
<img id="scooter-animation" src="./images/Man_On_Scooter.png" alt="Man on Electric Scooter">
<h1>welcome to suoto.</h1>
</div>
</section>
CSS:
/* Animated Scooter Slide-In */
#keyframes slide {
100% {
left: 0%;
}
}
#-webkit-keyframes slide {
100% {
left: 0%;
}
}
/* Animated Scooter Bounce on Hover */
#keyframes bounce {
0%,
100%,
20%,
50%,
80% {
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0)
}
40% {
-webkit-transform: translateY(-30px);
-ms-transform: translateY(-30px);
transform: translateY(-30px)
}
60% {
-webkit-transform: translateY(-15px);
-ms-transform: translateY(-15px);
transform: translateY(-15px)
}
}
#scooter-animation {
position: relative;
left: -200%;
-webkit-animation: slide 2s forwards;
-webkit-animation-delay: 0s;
animation: slide 2s forwards;
animation-delay: 0s;
animation-iteration-count: 1;
-webkit-animation-iteration-count: 1;
}
#scooter-animation:hover {
cursor: pointer;
animation-name: bounce;
-moz-animation-name: bounce;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
left: 0% !important;
}
Everything is running perfectly except as soon as the mouse hovers anywhere else on the webpage, the animation disappears from screen and slides in again when I only want this to happen once. Does anybody have any idea what it is I'm doing wrong?
Thank you for your answers and have a nice day!
I have changed your code structure a bit and added Javascript but It should work now. Basically I gave initial class name for your image and I cancelled this class name after first render. As a result cancelling initial css feature from image fixed the problem.
window.addEventListener('load', animate);
function animate() {
setTimeout(function(){ document.getElementById('scooter-animation').classList.remove('slide'); }, 3000);
}
/* Animated Scooter Slide-In */
#keyframes slide {
0% {
left: -200%;
}
}
#-webkit-keyframes slide {
100% {
left: 0%;
}
}
/* Animated Scooter Bounce on Hover */
#keyframes bounce {
0%,
100%,
20%,
50%,
80% {
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0)
}
40% {
-webkit-transform: translateY(-30px);
-ms-transform: translateY(-30px);
transform: translateY(-30px)
}
60% {
-webkit-transform: translateY(-15px);
-ms-transform: translateY(-15px);
transform: translateY(-15px)
}
}
#scooter-animation {
width:200px;
}
.slide {
position: relative;
-webkit-animation: slide 2s forwards;
-webkit-animation-delay: 0s;
animation: slide 2s 1;
animation-delay: 0s;
animation-iteration-count: 1;
-webkit-animation-iteration-count: 1;
}
#scooter-animation:hover {
cursor: pointer;
animation-name: bounce;
-moz-animation-name: bounce;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
left: 0%;
}
<body>
<section>
<!--Animation and Welcome Heading-->
<div class="welcome-container">
<img class='slide' id="scooter-animation" src="https://d2mvzyuse3lwjc.cloudfront.net/doc/en/UserGuide/images/Pie_Of_Pie_Chart/Pie_Of_Pie_Chart.png?v=83478" alt="Man on Electric Scooter">
<h1>welcome to suoto.</h1>
</div>
</section>
<body>

CSS3 animation fails to work in firefox

This animation isn't working in firefox, however it works fine in chrome, any ideas what might be wrong? Thanks!
CSS
.modular-template-wrapper .two-col-two-rows-img-txt-ocapi .sk-spinner-three-bounce div {
width: 8px;
height: 8px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background-color: #000;
display: inline-block;
-webkit-animation: sk-threeBounceDelay 1.4s infinite ease-in-out;
animation: sk-threeBounceDelay 1.4s infinite ease-in-out;
/* Prevent first frame from flickering when animation starts */
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
/* line 203, ../../sass/modules/qv-overlay.scss */
.modular-template-wrapper .two-col-two-rows-img-txt-ocapi .sk-spinner-three-bounce .sk-bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
/* line 206, ../../sass/modules/qv-overlay.scss */
.modular-template-wrapper .two-col-two-rows-img-txt-ocapi .sk-spinner-three-bounce .sk-bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
#-webkit-keyframes sk-threeBounceDelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
}
40% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes sk-threeBounceDelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
}
40% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
HTML
<div class="sk-spinner sk-spinner-three-bounce">
<div class="sk-bounce1"></div> <div class="sk-bounce2"></div>
<div class="sk-bounce3"></div>
</div>

Transform origin so animation don't jump

I have created an animated spinner, which is build using "slices of pizza" made of background gradient. The problem is I can't figure out what the origin should be. The animation keeps on jumping.
See the fiddle: http://jsfiddle.net/eqc05bkf/
How can I get rid of the jumping?
HTML:
<div class="slices bar">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS:
.slices {
width:100px;
height:100px;
position:relative;
transform-origin: right bottom;
-webkit-animation: spin 2.8s infinite steps(8);
-moz-animation: spin 2.8s infinite steps(8);
-ms-animation: spin 2.8s infinite steps(8);
-o-animation: spin 2.8s infinite steps(8);
animation: spin 2.8s infinite steps(8);
}
.slices.bar div {
width: 100%;
height: 100%;
position: absolute;
top: 35px;
left: 45px;
border-radius: 50%;
background: linear-gradient(45deg, #CDCDCD 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
transform-origin: 56px 52px;
/* container height / 2 */
}
#-webkit-keyframes spin {
to {
transform: rotate(1turn);
}
}
#-moz-keyframes spin {
to {
transform: rotate(1turn);
}
}
#-ms-keyframes spin {
to {
transform: rotate(1turn);
}
}
#keyframes spin {
to {
transform: rotate(1turn);
}
}
.slices.bar div:nth-child(1) {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
background: linear-gradient(45deg, red 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
}
.slices.bar div:nth-child(2) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.slices.bar div:nth-child(3) {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.slices.bar div:nth-child(4) {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.slices.bar div:nth-child(5) {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.slices.bar div:nth-child(6) {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
.slices.bar div:nth-child(7) {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.slices.bar div:nth-child(8) {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
I modified your code a bit. Primarily, I added a container div and simply rotated that. fiddle
HTML:
<div id='hold'>
<div class="slices bar">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
CSS:
.slices {
width:100px;
height:100px;
position:relative;
margin-top: -31px;
margin-left: -45px;
transform-origin: right bottom;
/*-webkit-animation: spin 2.8s infinite steps(8);
-moz-animation: spin 2.8s infinite steps(8);
-ms-animation: spin 2.8s infinite steps(8);
-o-animation: spin 2.8s infinite steps(8);
animation: spin 2.8s infinite steps(8);*/
}
#hold {
width: 112px;
height: 112px;
border-radius: 50%;
overflow: hidden;
-webkit-animation: spin 2.8s infinite steps(8);
-moz-animation: spin 2.8s infinite steps(8);
-ms-animation: spin 2.8s infinite steps(8);
-o-animation: spin 2.8s infinite steps(8);
animation: spin 2.8s infinite steps(8);
}
.slices.bar div {
width: 100%;
height: 100%;
position: absolute;
top: 35px;
left: 45px;
border-radius: 50%;
background: linear-gradient(45deg, #CDCDCD 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
transform-origin: 56px 52px;
/* container height / 2 */
}
#-webkit-keyframes spin {
to {
transform: rotate(1turn);
}
}
#-moz-keyframes spin {
to {
transform: rotate(1turn);
}
}
#-ms-keyframes spin {
to {
transform: rotate(1turn);
}
}
#keyframes spin {
to {
transform: rotate(1turn);
}
}
.slices.bar div:nth-child(1) {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
background: linear-gradient(45deg, red 50%, transparent 50%) 0 0;
background-repeat: no-repeat;
background-size: 50% 50%;
}
.slices.bar div:nth-child(2) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.slices.bar div:nth-child(3) {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.slices.bar div:nth-child(4) {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.slices.bar div:nth-child(5) {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.slices.bar div:nth-child(6) {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
.slices.bar div:nth-child(7) {
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.slices.bar div:nth-child(8) {
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}

Internet Explorer 11 wobbly CSS3 animation

Please refer to this fiddle: http://jsfiddle.net/eQegA/3/
<div class="spinner"></div>
.spinner {
width: 100px;
height: 100px;
border: 50px solid blue;
/*border-top-color: #fff;
border-bottom-color: #fff;*/ /* commented out to see the wobble better */
border-radius: 200px;
-webkit-animation: application-loading-rotate 1s;
animation: application-loading-rotate 1s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
}
#-webkit-keyframes application-loading-rotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes application-loading-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
In Google Chrome the rotation is stable, however for some reason in IE11 there is a noticable "wobble" of the circle as it rotates.
Any ideas why it wobbles so? Is there any way to fix it in IE11?
For what it's worth, it also occurs on other browsers. It has to do, how the border is drawn, it's not a perfect round. As far as I know, there isn't a quick fix for this. However you can draw the border as a background image.
.spinner {
display:block;
width: 200px;
height: 200px;
border-radius: 100%;
background-image:url(http://www.clipartbest.com/cliparts/9iR/RyK/9iRRyKLie.png);
background-size:100%;
-webkit-animation: application-loading-rotate 1s;
animation: application-loading-rotate 1s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
}
#-webkit-keyframes application-loading-rotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes application-loading-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
See:
http://jsfiddle.net/eQegA/26/

css3 keyframes hover animation firefox

I created some keyframes animation to animate div on mouse hover in pure css3.
It works great in every browsers (google chrome, safari, IE, opera) execpted in FIREFOX!
I really don't know why it didn't works only in firefox. The animation won't works on mouseover but works on load....
Here a css example of keyframe :
#-webkit-keyframes swing {
20%, 40%, 60%, 80%, 100% { -webkit-transform-origin: top center; }
20% { -webkit-transform: rotate(15deg); }
40% { -webkit-transform: rotate(-10deg); }
60% { -webkit-transform: rotate(5deg); }
80% { -webkit-transform: rotate(-5deg); }
100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes swing {
20% { -moz-transform: rotate(15deg); }
40% { -moz-transform: rotate(-10deg); }
60% { -moz-transform: rotate(5deg); }
80% { -moz-transform: rotate(-5deg); }
100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes swing {
20% { -o-transform: rotate(15deg); }
40% { -o-transform: rotate(-10deg); }
60% { -o-transform: rotate(5deg); }
80% { -o-transform: rotate(-5deg); }
100% { -o-transform: rotate(0deg); }
}
#keyframes swing {
20% { transform: rotate(15deg); }
40% { transform: rotate(-10deg); }
60% { transform: rotate(5deg); }
80% { transform: rotate(-5deg); }
100% { transform: rotate(0deg); }
}
.col:hover .swing {
-webkit-transform-origin: top center;
-moz-transform-origin: top center;
-o-transform-origin: top center;
transform-origin: top center;
-webkit-animation: swing 1s linear;
-moz-animation: swing 1s linear;
-o-animation: swing 1s linear;
animation: swing 1s linear;
}
.swing {
-webkit-transform-origin: top center;
-moz-transform-origin: top center;
-o-transform-origin: top center;
transform-origin: top center;
-webkit-animation: swing 1s linear 1s;
-moz-animation: swing 1s linear 1s;
-o-animation: swing 1s linear 1s;
animation: swing 1s linear 1s;
}
.col,
.th-icon {
position: relative;
margin: 40px 0 0 100px;
width: 200px;
height: 200px;
}
i.swing {
display: block;
width: 200px;
height: 200px;
background: grey;
}
And the fiddle: http://jsfiddle.net/ktxDp/1/
May be Firefox doesn't allow same animation twice.
It worked when I called the animation only once. Working Demo
.col:hover .swing {
-webkit-transform-origin: top center;
-moz-transform-origin: top center;
-o-transform-origin: top center;
transform-origin: top center;
-webkit-animation: swing 1s linear;
-moz-animation: swing 1s linear;
-o-animation: swing 1s linear;
animation: swing 1s linear;
}

Resources