I'm trying to get several animations running at the time in a small banner. A change of position with an opacity change in the first line of text, a simple opacity change in another one and so on. The problem is that the first animation works perfectly and the second one (and everything after that) never runs. I used exactly the same code as in the first one and just changed the name of the animation as well as the class but it's still not working.
This is the code I used for the first ones, (H1 works just fine but h2, h3 and the rest of the animation don't)
My HTML
<h1> Smart travel,
<br> at your fingertips. </h1>
<h2> Our app for Iphone and Ipad is here </h2>
<h3><strong>Download </strong> it today. </h3>
My CSS (By the way, some lines above all of this is set up as position: absolute)
h1 {
position: relative;
right: 0px;
-webkit-animation: mymove 1s ; /* Chrome, Safari, Opera */
animation: mymove 1s ;
animation-timing-function: linear;
-webkit-animation-timing-function: linear;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% {
transform: opacity: 0;
}
25% {transform: translate3d(90px, 0px, 0px);
opacity:0;
}
100% {
transform: translate3d(0px, 0px, 0px);
opacity: 100;
}
h2 {
position: relative;
-webkit-animation: mymove2 3s ; /* Chrome, Safari, Opera */
animation: mymove2 3s ;
animation-timing-function: linear;
-webkit-animation-timing-function: linear;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove2 {
0% {
opacity: 0;
}
50% {
opacity:0;
}
100% {
opacity: 100;
}
You didn't close this #-webkit-keyframes mymove { Check this fiddle
h1 {
position: relative;
right: 0px;
-webkit-animation: mymove 1s;
/* Chrome, Safari, Opera */
animation: mymove 1s;
animation-timing-function: linear;
-webkit-animation-timing-function: linear;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
0% {
transform: opacity: 0;
}
25% {
transform: translate3d(90px, 0px, 0px);
opacity:0;
}
100% {
transform: translate3d(0px, 0px, 0px);
opacity: 100;
}
}
h2 {
position: relative;
-webkit-animation: mymove2 3s;
/* Chrome, Safari, Opera */
animation: mymove2 3s;
animation-timing-function: linear;
-webkit-animation-timing-function: linear;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove2 {
0% {
opacity: 0;
}
50% {
opacity:0;
}
100% {
opacity: 100;
}
<h1> Smart travel,
<br> at your fingertips. </h1>
<h2> Our app for Iphone and Ipad is here </h2>
<h3><strong>Download </strong> it today. </h3>
I guess this comes from an error in your CSS code :
transform: opacity: 0; /* Syntax error there */
/* should be */
opacity: 0;
transform: translate3d(0px, 0px, 0px); /* or whatever starting value you want */
You should also note that you have prefixed the keyframes of your animation (#-webkit-keyframes mymove), this can only work on wekbit based browsers.
The last brace is missing, but it's not considered as an error (the last brace / semicolon are optional).
Related
The title basically gives it away. I have an animation working just fine in Chrome (80) and Firefox (57), but does not work in Safari (12) at all.
What I expect to happen is a straight line is drawn across the screen diagonally, from left top to right bottom.
I've tried a dozen variations of my code, the following is one:
(all the variations I tried work perfectly fine in Chrome and Firefox)
#move {
top:0;
left:0;
width: 0;
height: 5px;
background: rgb(255, 255, 255);
position: absolute;
-webkit-animation-name: mymove;
-webkit-animation-duration: 3s;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: forwards;
-webkit-transform: rotate(var(--a));
-webkit-transform-origin: top left;
-webkit-animation-delay: 1s;
-moz-animation-name: mymove;
-moz-animation-duration: 3s;
-moz-animation-timing-function: linear;
-moz-animation-fill-mode: forwards;
-moz-transform: rotate(var(--a));
-moz-transform-origin: top left;
-moz-animation-delay: 1s;
-ms-animation-name: mymove;
-ms-animation-duration: 3s;
-ms-animation-timing-function: linear;
-ms-animation-fill-mode: forwards;
-ms-transform: rotate(var(--a));
-ms-transform-origin: top left;
-ms-animation-delay: 1s;
-o-animation-name: mymove;
-o-animation-duration: 3s;
-o-animation-timing-function: linear;
-o-animation-fill-mode: forwards;
-o-transform: rotate(var(--a));
-o-transform-origin: top left;
-o-animation-delay: 1s;
animation-name: mymove;
animation-duration: 3s;
animation-timing-function: linear;
animation-fill-mode: forwards;
transform: rotate(var(--a));
transform-origin: top left;
animation-delay: 1s;
}
#-webkit-keyframes mymove {
to {
width: var(--w);
/*background-color: rgb(67, 67, 92);*/
}
}
#-moz-keyframes mymove {
to {
width: var(--w);
/*background-color: rgb(67, 67, 92);*/
}
}
#-ms-keyframes mymove {
to {
width: var(--w);
/*background-color: rgb(67, 67, 92);*/
}
}
#-o-keyframes mymove {
to {
width: var(--w);
/*background-color: rgb(67, 67, 92);*/
}
}
#keyframes mymove {
to {
width: var(--w);
/*background-color: rgb(67, 67, 92);*/
}
}
a shorter one:
#move {
top:0;
left:0;
width: 0;
height: 5px;
background: rgb(255, 255, 255);
position: absolute;
animation: mymove 3s;
animation-fill-mode: forwards;
transform-origin: top left;
transform: rotate(var(--a));
}
#keyframes mymove {
to {
width: var(--w);
}
}
The HTML:
<div id="move"></div>
I tried to consider:
webkit:
Why is my CSS3 animation not working in Chrome or Safari?
CSS3 animation: Not loading in Safari
Transform: rotate doesn't work in Safari
Splitting up the shorthand notation:
CSS3 animation not working in safari
Delaying the animation:
CSS3 animation not working in safari
None of what I tried seem to work in Safari. What am I missing here? Any help would be very much appreciated!
I had a very similar issue. Like the OP, I was setting up the keyframe using the 'to' property:
#keyframes dash {
to {
dash-offset: 0;
}
}
This seems to be fine with Chrome and Firefox. I discovered that Safari and iOS Safari require the 'from' property to be set as well. This is contrary to MDN's claim that 'If a keyframe rule doesn't specify the start or end states of the animation (that is, 0%/from and 100%/to), browsers will use the element's existing styles for the start/end states.'
I was animating a dynamic element, so I ended up using the Web Animations API to describe an animation that all browsers could understand:
const lineAnimationTiming: EffectTiming = {
duration: 1000,
easing: 'ease-in-out'
};
const length = line.getTotalLength();
line.style.strokeDasharray = `${length} ${length}`;
line.animate(
[
{ strokeDashoffset: length },
{ strokeDashoffset: 0 }
],
lineAnimationTiming
);
EDIT Sep 3, 2021:
Testing Safari using vanilla HTML/Javascript/CSS, this issue does not reproduce. See this Stackblitz.
I happened to be using Angular when I first encountered the issue. This issue does reproduce there. See this Stackblitz. Reported to Angular as this bug.
I'm trying to have a scrolling marquee of sorts across the top of my webpage. I'm not using the tag as it is not supported by Safari. However, even with using CSS Animation, it doesn't seem to work for Safari either. Here's my code:
<h3>Upcoming Shows:...</h3>
This is what I have in my style sheet:
h3 {
position: absolute;
width: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
/* Starting position */
-moz-transform:translateX(100%);
-webkit-transform:translateX(100%);
transform:translateX(100%);
/* Apply animation to this element */
-moz-animation: example1 15s linear infinite;
-webkit-animation: example1 15s linear infinite;
animation: example1 15s linear infinite;
}
/* Move it (define the animation) */
#-moz-keyframes example1 {
0% { -moz-transform: translateX(100%); }
100% { -moz-transform: translateX(-100%); }
}
#-webkit-keyframes example1 {
0% { -webkit-transform: translateX(100%); }
100% { -webkit-transform: translateX(-100%); }
}
#keyframes example1 {
0% {
-moz-transform: translateX(100%); /* Firefox bug fix */
-webkit-transform: translateX(100%); /* Firefox bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%); /* Firefox bug fix */
-webkit-transform: translateX(-100%); /* Firefox bug fix */
transform: translateX(-100%);
}
}
This question already has answers here:
Stopping a CSS3 Animation on last frame
(8 answers)
Closed 7 years ago.
Look at the css below. bottom:0 doesn't get applied at all once the animation is over
div {
width: 100%;
position: absolute;
z-index: 999;
background: black;
color: white;
padding: 10px;
font-weight: bold;
-webkit-animation: mymove 1s; /* Chrome, Safari, Opera */
animation: mymove 1s;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
}
div:empty {
-webkit-animation: mymoveClose 1s; /* Chrome, Safari, Opera */
animation: mymoveClose 1s;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
from {bottom: -30px;}
to {bottom: 0px;}
}
/* Standard syntax */
#keyframes mymove {
from {bottom: -30px;}
to {bottom: 0px;}
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymoveClose {
from {bottom: 0px;}
to {bottom: -30px;}
}
/* Standard syntax */
#keyframes mymoveClose {
from {bottom: 0px;}
to {bottom: -30px;}
}
Here is the fiddle
http://jsfiddle.net/uk4gxr8c/
You need to specify an animation-fill-mode.
In this case forwards will cause the animation to end at the final value.
Per MDN
The target will retain the computed values set by the last keyframe encountered during execution. The last keyframe encountered depends on the value of animation-direction and animation-iteration-count:
setTimeout(function() {
document.getElementById('div1').innerHTML = '';
}, 3000);
div {
width: 100%;
position: absolute;
z-index: 999;
background: black;
color: white;
padding: 10px;
height: 30px;
font-weight: bold;
box-sizing: border-box;
-webkit-animation: mymoveClose 1s;
/* Chrome, Safari, Opera */
animation: mymoveClose 1s linear forwards;
}
div:empty {
-webkit-animation: mymove 1s;
/* Chrome, Safari, Opera */
animation: mymove 1s linear forwards;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
from {
bottom: -30px;
}
to {
bottom: 0px;
}
}
/* Standard syntax */
#keyframes mymove {
from {
bottom: -30px;
}
to {
bottom: 0px;
}
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymoveClose {
from {
bottom: 0px;
}
to {
bottom: -30px;
}
}
/* Standard syntax */
#keyframes mymoveClose {
from {
bottom: 0px;
}
to {
bottom: -30px;
}
}
<div id="div1">linear</div>
Im trying to create an animation for a "help window". I would like it to start or have the the image/animation after X seconds, but am having issues as the animation-delay property isn't applicable here as it pauses the still image before playing it.
Any ideas for webkits or properties to try here?
See link here;
http://hardystewartdesign.com/dist/project.html
.hello {
width: 211px;
height: 115px;
background: none;
position: fixed;
bottom: 0px;
left: 0px;
-webkit-animation: mymove 3s; /* Chrome, Safari, Opera */
-webkit-animation-iteration-count: 1; /* Chrome, Safari, Opera */
-webkit-animation-fill-mode: forwards; /* Chrome, Safari, Opera */
animation: mymove 3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes mymove {
from {left: -300px;}
to {left: 0px;}
}
#keyframes mymove {
from {left: -300px;}
to {left: 0;}
}
just change left: 0 to left: -300px in the .hello class
I have looked at different answers posted on here but nothing has worked for me...
What: I have a div that is scaled down to 0.6 and when called should scale up to 1 (100%).
Problem: In Firefox #myDiv is scaling up as intended, but nothing happens in Chrome or Safari (on mac).
I have this DIV code:
#myDiv {
-moz-animation: changeSize 1s ease-out .5s forwards; /* Fx 5+ */
-webkit-animation: changeSize 1s ease-out .5s 0 forwards; /* Safari 4+ */
-o-animation: changeSize 1s ease-out .5s forwards; /* Opera */
-webkit-transform: scale(0.6);/* Saf3.1+, Chrome */
-moz-transform: scale(0.6); /* FF3.5+ */
-ms-transform: scale(0.6); /* IE9 */
-o-transform: scale(0.6); /* Opera 10.5+ */
transform: scale(0.6);
display: inline-block;
opacity:100;
background-image: url(img.png);
width: 154px;
height: 28px;
position: absolute;
left: 145px;
top: 5px;
}
And the keyframe animation for the scale up transition:
#keyframes changeSize {
0% {transform:scale(0.6)}
100% {transform: scale(1)}
}
#-moz-keyframes changeSize /* Firefox */ {
0% {transform:scale(0.6)}
100% {transform:scale(1)}
}
#-webkit-keyframes changeSize /* Safari and Chrome */{
0% {transform:scale(0.6)}
100% {transform:scale(1)}
}
#-o-keyframes changeSize /* Opera */ {
0% {transform:scale(0.6)}
100% {transform:scale(1)}
}
The HTML:
Please advise what I am missing here!
Thanks!
Your error is in this line :
-webkit-animation: changeSize 1s ease-out .5s 0 forwards;
There is an unnecessary 0!
Lastly,
#-moz-keyframes changeSize /* Firefox */ {
0% {transform:scale(0.6)}
100% {transform:scale(1)}
}
#-webkit-keyframes changeSize /* Safari and Chrome */{
0% {transform:scale(0.6)}
100% {transform:scale(1)}
}
#-o-keyframes changeSize /* Opera */ {
0% {transform:scale(0.6)}
100% {transform:scale(1)}
}
Within these keyframes, you're missing something. None of the transform property have browser support prefixes. For example:
#-webkit-keyframes changeSize /* Safari and Chrome */{
0% {-webkit-transform:scale(0.6)}
100% {**-webkit-**transform:scale(1)}
}
I added -webkit- prefix to the transform property now it will display in Google Chrome and Safari.
Side note: you might have some unnecessary code blocks. -moz-,-ms-, and -o-.