Having an issue with my CSS3 animation in Firefox and Safari. It works like a charm in Chrome and Internet Explorer. Spent a while attempting to figure this out myself, but no success. I followed all of the rules I could find, but I must be missing something.
HTML
<div class="background">
<div id="canvas" class="loading"></div>
CSS
.background {
background:#333;
padding-bottom: 140px;
padding-top: 65px;
}
#canvas.loading {
-webkit-animation: animate 1.5s linear infinite;
-moz-animation: animate 1.5s linear infinite;
animation: animate 1.5s linear infinite;
clip: rect(0, 80px, 80px, 40px);
height: 80px;
width: 80px;
position:absolute;
left:45%;
}
#-webkit-keyframes animate {
0% {
transform: rotate(0deg)
}
100% {
transform: rotate(220deg)
}
}
#keyframes animate {
0% {
transform: rotate(0deg)
}
100% {
transform: rotate(220deg)
}
}
#-moz-keyframes animate {
0% {
transform: rotate(0deg)
}
100% {
transform: rotate(220deg)
}
}
#canvas.loading:before {
-webkit-animation: animate2 1.5s ease-in-out infinite;
-moz-animation: animate 1.5s linear infinite;
animation: animate2 1.5s ease-in-out infinite;
clip: rect(0, 80px, 80px, 40px);
content:'';
border-radius: 50%;
height: 80px;
width: 80px;
position:absolute
}
#-webkit-keyframes animate2 {
0% {
box-shadow: inset #5AA0E7 0 0 0 17px;
transform: rotate(-140deg);
}
50% {
box-shadow: inset #5AA0E7 0 0 0 2px;
}
100% {
box-shadow: inset #5AA0E7 0 0 0 17px;
transform: rotate(140deg);
}
}
#-moz-keyframes animate2 {
0% {
box-shadow: inset #5AA0E7 0 0 0 17px;
transform: rotate(-140deg);
}
50% {
box-shadow: inset #5AA0E7 0 0 0 2px;
}
100% {
box-shadow: inset #5AA0E7 0 0 0 17px;
transform: rotate(140deg);
}
}
#keyframes animate2 {
0% {
box-shadow: inset #5AA0E7 0 0 0 17px;
transform: rotate(-140deg);
}
50% {
box-shadow: inset #5AA0E7 0 0 0 2px;
}
100% {
box-shadow: inset #5AA0E7 0 0 0 17px;
transform: rotate(140deg);
}
}
Here is the JSFIDDLE: http://jsfiddle.net/myo4r9kk/
Any help would be greatly appreciated!
Works for me in FF 35, can't say more than that.
Safari needs the transform property to be prefixed, so changing your css to the following will make it work (only included the relevant parts):
#-webkit-keyframes animate {
0% {
-webkit-transform: rotate(0deg)
transform: rotate(0deg)
}
100% {
-webkit-transform: rotate(220deg)
transform: rotate(220deg)
}
}
#-webkit-keyframes animate2 {
0% {
box-shadow: inset #5AA0E7 0 0 0 17px;
-webkit-transform: rotate(-140deg);
transform: rotate(-140deg);
}
50% {
box-shadow: inset #5AA0E7 0 0 0 2px;
}
100% {
box-shadow: inset #5AA0E7 0 0 0 17px;
-webkit-transform: rotate(140deg);
transform: rotate(140deg);
}
}
It's probably best to change your #keyframes in the same way, just in case Safari one day supports unprefixed #keyframes but still needs prefixed transform rule.
And one last thing: It is generally considered safest to put the prefixed versions of a property before the standard version. I'm not totally sure but I guess that applies to keyframes as well, so you might want to put your #-moz-keyframes before your #keyframes. That may even solve your problems with Firefox (assuming a working implementation of the standard gets overwritten by a buggy version because you put the prefixed after the standard.
I took the liberty to update your fiddle with all those changes: http://jsfiddle.net/myo4r9kk/2/
EDIT
I just found this in your code:
-webkit-animation: animate2 1.5s ease-in-out infinite;
-moz-animation: animate 1.5s linear infinite;
animation: animate2 1.5s ease-in-out infinite;
Maybe that explains the problems with Firefox, are you by any chance testing this on FF < 15? In any case that -moz-animation should be the same as the other two.
Related
How can I make this Image with infinite glow animation to spin at the same time using css. Am trying to use two animations at once.
I want to make it spin indefinitely.
.topbar-artwork img{
animation: glowing 600ms infinite;
}
#keyframes glowing {
0% { box-shadow: 0 0 -10px #000; }
40% { box-shadow: 0 0 20px #000; }
60% { box-shadow: 0 0 20px #000; }
100% { box-shadow: 0 0 -10px #000; }
}
<div class="topbar-artwork">
<img src="https://i.imgur.com/0INjJXJ.jpg">
</div>
You can simply add another animation:
.topbar-artwork img {
animation: glowing 600ms infinite,
spin 2s infinite linear;
}
#keyframes glowing {
0% {
box-shadow: 0 0 0px #000;
}
40% {
box-shadow: 0 0 20px #000;
}
60% {
box-shadow: 0 0 20px #000;
}
100% {
box-shadow: 0 0 0px #000;
}
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div class="topbar-artwork">
<img src="https://i.imgur.com/0INjJXJ.jpg">
</div>
To implement the rotation function, use the css property transform: rotate(deg)
.topbar-artwork img{
animation: glowing 600ms infinite;
animation-timing-function: linear;
}
#keyframes glowing {
0% { box-shadow: 0 0 -10px #000; transform: rotate(0deg);}
40% { box-shadow: 0 0 20px #000; }
60% { box-shadow: 0 0 20px #000; }
100% { box-shadow: 0 0 -10px #000; transform: rotate(360deg);}
}
<div class="topbar-artwork">
<img src="https://i.imgur.com/0INjJXJ.jpg">
</div>
I making a button with animated img on it. So when you hover on, car goes from left, and stops in center. And when you hover out - car goes to right.
I've made a fiddle:
https://jsfiddle.net/ufwyjd0o/
.button{
height:150px;
width: 150px;
background-color:#468189;
margin: 100px;
border-radius: 100%;
box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.6);
animation: size 1.5s infinite alternate;
position: relative;
}
#keyframes size {
0% {transform: scale(1.0);
box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.6); }
100% {transform: scale(1.05);
box-shadow: 0px 8px 8px 0px rgba(0,0,0,0.4); }
}
.icon img{
height:75px;
width:auto;
position: absolute;
top: 40px;
animation: driveout 1s cubic-bezier(.52,.02,.31,.99) both;
transform: 1s;
}
#keyframes drive {
0% {transform: translate3d(-60px,0,0)}
5% {transform: translate3d(60px,0,0)}
10% {transform: translate3d(40px,0,0);}
}
#keyframes driveout {
0% {transform: translate3d(40px,0,0)}
100% {transform: translate3d(200px,0,0)}
}
.button:hover .icon img {
animation: drive 10s cubic-bezier(.52,.02,.31,.99) normal;
animation-play-state: pause;
display:block;
}
If you want different animations on hoveron and hoverout (same as mouseover and mouseout in javascript) then your best bet would be something like this.
.button {
// what you want to happen on hoverout
animation: // your hoverout animation
}
.button:hover {
// what you want to happen on hoverover
animation: // your hoverover animation.
}
I have a scrolling banner that will not work in IE. Works fine in Firefox, Chrome, and Opera though. Here is my HTML:
<div id="container">
<div class="photobanner">
<a class="first" href="http://www.site1.com" ><img src="/images/image1.jpg" alt="site1"></img></a>
<img src="/images/site2.jpg" alt="site2"></img>
<img src="/images/image3.jpg" alt="site3"></img>
<img src="/images/image4.jpg" alt="site4"></img>
</img>
<img src="/images/image2.jpg" alt="site2"></img>
</div>
</div>
It is my understanding that -ms-transform should work in IE9 and beyond but that doesn't seem to be the case, here is my CSS:
.photobanner {
width: 3805px;
}
.photobanner img {
height: 175px;
margin: 25px 0px 25px 0px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.photobanner img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
cursor: pointer;
-webkit-box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
}
/*keyframe animations*/
.first {
-webkit-animation: bannermove 30s linear infinite;
-moz-animation: bannermove 30s linear infinite;
-ms-animation: bannermove 30s linear infinite;
-o-animation: bannermove 30s linear infinite;
animation: bannermove 30s linear infinite;
}
#keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
#-moz-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
#-webkit-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
#-ms-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
#-o-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
Any ideas how I can get this to work???
Just remove the " quote from your #keyframes name. Like this:
#-webkit-keyframes bannermove {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
#keyframes bannermove {
0% {
margin-left: 0px;
}
100% {
margin-left: -2545px;
}
}
http://jsfiddle.net/z5ep9hjk/1/
Also it won't run on IE 9 http://caniuse.com/#feat=css-animation Because it is not support animation property.
You have to remove the double quotes ( " ) from the #keyframes. It'll then work in IE11.
I tried adding -moz- but it doesnt wave.. it works on chrome but not on mozilla firefox
I don't know whats wrong with it.. and help would be appreciated.. I doesnt animate on mozilla firefox :(
here is the code
<ul class="notes-dance">
<li>♩</li>
<li>♪</li>
<li>♫</li>
<li>♪</li>
<li>♫</li>
<li>♬</li>
<li>♩</li>
<li>♫</li>
<li>♬</li>
<li>♩</li>
</ul>
and the css code :
ul li {
display: block;
float: left;
font-size: 2em;
color: #ccc;
text-shadow: 0 -1px 0 white, 0 1px 0 black;
}
.anim {
-moz-animation: music 1s ease-in-out both infinite;
-webkit-animation: music 1s ease-in-out both infinite;
animation : music 1s ease-in-out both infinite;
}
#-webkit-keyframes music {
0%,100% {
-moz-transform: translate3d(0,-10px,0);
-webkit-transform: translate3d(0,-10px,0);
transform: translate3d(0,-10px,0);
}
50% {
-moz-transform: translate3d(0,10px,0);
-webkit-transform: translate3d(0,10px,0);
transform: translate3d(0,10px,0);
}
}
#-moz-keyframes music {
0%,100% {
transform: translate3d(0,-10px,0);
}
50% {
transform: translate3d(0,10px,0);
}
}
.notes-dance{
left: 30%;
right: 50px;
top: 90%;
position: absolute;
}
Use This One for #-moz-keyframes
#-moz-keyframes music {
0% {-moz-transform: translate3d(0,-10px,0);}
50% {-moz-transform: translate3d(0,10px,0);}
100% {-moz-transform: translate3d(0,-10px,0);}
}
You added #-moz-keyframes with no -moz-transform !! and you added -moz-transform to #-webkit-keyframes
As per http://caniuse.com/#feat=css-animation:
#keyframes not supported in an inline or scoped stylesheet in Firefox (bug 830056)
Are you using it in an inline or scoped way? If so, there's your answer.
I am trying to achieve an infinite blink and rotation together, but the problem I face is quite weird, the blinking which should occur at a regular interval of 500ms, happens nicely for a while then disappears and appears back again.
Also I went through lot of questions around blinking but my test case is different. I can't keep the 0% 50% 100% in the keyframes to get the blinking working because I'd want the span to blink at a particular percentage I specify.
For example: I'd want the span to blink at 100deg or 90deg, so I should be able to specify the blink timing by specifying the exact percentage value.
Here's my work so far, any help would be appreciated. http://jsfiddle.net/8UQ8X/7/ (includes vendor prefixes)
<div>
<span></span>
</div>
<style>
div{
position: fixed;
width:3px;
height:100px;
left: 300px;
top: 100px;
border: 1px rgba(255,255,255,0.1) solid;
-webkit-animation: spin 500ms steps(30) infinite;
-webkit-transform-origin: center center;
-webkit-transform: translate3d(0, 0, 0);
}
span{
display:block;
width: 2px;
height: 2px;
border-radius: 50%;
-webkit-animation: blink 500ms infinite steps(1);
}
#-webkit-keyframes spin {
from{
-webkit-transform: rotate(0deg)
}
to{
-webkit-transform: rotate(360deg)
}
}
#-webkit-keyframes blink {
// I should be able to any percentage value to get the span blink at a particular degree.
// for now I am trying to blink the span at 0%, the beginning, later I might change it to 50% or something
0% {background: #fff}
1% {background: none;}
}
body{
background: #232323;
}
</style>
Try this : Animation
.i{
position: fixed;
width:10px;
height:150px;
left: 300px;
top: 100px;
border: 1px rgba(255,255,255,0.1) solid;
-webkit-animation: spin 500ms steps(30) infinite;
-webkit-transform-origin: center center;
-webkit-transform: translate3d(0, 0, 0);
-moz-animation: spin 500ms steps(30) infinite;
-moz-transform-origin: center center;
-moz-transform: translate3d(0, 0, 0);
-webkit-animation-timing-function:ease-in-out;
}
span{
display:block;
width: 10px;
height: 10px;
border: 1px rgba(255,255,255,0.1) solid;
border-radius: 50%;
-webkit-animation: blink 500ms infinite steps(1);
-moz-animation: blink 500ms infinite steps(1);
-webkit-animation-timing-function:liner;
}
#-webkit-keyframes spin {
from{
-webkit-transform: rotate(0deg)
}
to{
-webkit-transform: rotate(360deg)
}
}
#-moz-keyframes spin {
from{
-moz-transform: rotate(0deg)
}
to{
-moz-transform: rotate(360deg)
}
}
#-webkit-keyframes blink {
0% {background: #fff}
1% {background: none;}
}
#-moz-keyframes blink {
0% {background: #fff}
1% {background: none;}
}
body{
background: #232323;
}