CSS keyframes (animation) not functioning in safari - html

I am currently facing some issues with CSS's #keyframes, as they do not seem to work to work on Safari browser. They are working fine on Chrome, though.
I have checked with the list of WebKit CSS extensions, but I do not seem to have any luck with it.
.app-loading {
}
.app-loading .spinner {
height: 200px;
width: 200px;
animation: rotate 2s linear infinite;
-webkit-animation: rotate 2s linear infinite;
transform-origin: center center;
-webkit-transform-origin: center center;
position: absolute;
top: 0;
bottom: 10;
margin: auto;
}
.app-loading .spinner .path {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
-webkit-animation: dash 1.5s ease-in-out infinite;
stroke-linecap: round;
stroke: #ddd;
}
#keyframes rotate {
100% {
transform: rotate(360deg);
}
}
#-webkit-keyframes rotate {
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35px;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124px;
}
}
#-webkit-keyframes dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35px;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124px;
}
}
<div class="app-loading">
<svg class="spinner" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
</svg>
</div>
I have also created a demo on JSfiddle.
I understand there are many similar questions out there, but none of them seem to be solving the issue I am facing right now:
1) CSS Keyframe animations safari
2) CSS3 animation not working in safari
Would appreciate some help over here. Thanks!
EDIT 1:
What other things I've tried - replacing the -webkit-animation shorthand with the below
-webkit-animation-name: rotate;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: infinite;

In Safari the shorthand notation does not work.
So this will not work :
-webkit-animation: rotate 2s linear infinite;
Instead try writing your animation in full form like this :
-webkit-animation-name: rotate;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-webkit-animation-fill-mode: infinite;
Do the same to your other animation as well and see if it works

I faced the same problem with Safari, using expanded properties for Keyframes, and what fixed the problem for me was using the absolute strict shorthand definition:
/* #keyframes duration | timing-function | delay |
iteration-count | direction | fill-mode | play-state | name */
animation: 3s ease-in 1s 2 reverse both paused slidein;
Note that the keyframe name is at the end of the definition, I think that could be the problem.
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/animation
Please also note that recent versions of Safari don't use -webkit- prefix so there's no need to add that if your platform doesn't aim for retrocompatibility.

Related

SVG text with ‘stroke-dashoffset’ CSS animation not working in Firefox

The following animation works fine in Chrome and Opera, but it doesn't work in Mozilla Firefox. I can't figure out why.
Can someone please help me to fix the problem? What is wrong with my CSS?
#text-logo {
font-family: 'Shrikhand', cursive;
stroke-dashoffset: 100%;
stroke-dasharray: 100%;
-moz-animation: draw 8s forwards ease-in;
-webkit-animation: draw 8s forwards ease-in;
animation: draw 8s forwards ease-in;
background-clip: text;
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-moz-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
<div class="draw_text">
<svg width="1092" height="220">
<text x="150" y="200" fill="#fff" stroke="#333" id="text-logo" stroke-width="2" font-size="95">WHO I AM ?</text>
</svg>
</div>
Units have to match in Firefox so if the base is a percentage unit then the animated value must be in percentages too.
There's no such thing as a -moz-animation or -moz-keyframes and any prefixed animations should be placed before the unprefixed version. I've fixed that too below.
#text-logo {
font-family: 'Shrikhand', cursive;
stroke-dashoffset: 100%;
stroke-dasharray: 100%;
-webkit-animation: draw 8s forwards ease-in;
animation: draw 8s forwards ease-in;
background-clip: text;
}
#-webkit-keyframes draw {
100% {
stroke-dashoffset: 0%;
}
#keyframes draw {
100% {
stroke-dashoffset: 0%;
}
}
}
<div class="draw_text">
<svg width="1092" height="220">
<text x="150" y="200" fill="#fff" stroke="#333" id="text-logo" stroke-width="2" font-size="95">WHO I AM ?</text>
</svg>
</div>
Setting stroke-dashoffset: 100% looks like a neat thing, but 100% of what? The canonical definition is:
If a percentage is used, the value represents a percentage of the current viewport …
… the percentage is calculated as the specified percentage of sqrt((actual-width)**2 + (actual-height)**2))/sqrt(2).
Firefox seems to not implement that. Setting px lengths makes it work:
#text-logo {
font-family: 'Shrikhand', cursive;
stroke-dashoffset: 1114px;
stroke-dasharray: 1114px;
-moz-animation: draw 8s forwards ease-in;
-webkit-animation: draw 8s forwards ease-in;
animation: draw 8s forwards ease-in;
background-clip: text;
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-moz-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
<div class="draw_text">
<svg width="1092" height="220">
<text x="150" y="200" fill="#fff" stroke="#333" id="text-logo" stroke-width="2" font-size="95">WHO I AM ?</text>
</svg>
</div>

svg animation not displaying properly in Chrome

I've created a CSS SVG animation of a frame being drawn onto the stage. The animation works correctly, but there seems to be an issue mostly in Chrome. The stage should be blank before the animation begins and the frame, made up of 4 segments, "draws" in segment by segment. In some versions of Chrome, however, before the animation begins there are 4 dots on the stage. The dots are the beginning points of each segment of the frame and shouldn't be visible.
In a few versions of Chrome that I've tested it on (47.0.2526.106 on a Mac, 47.0.2526.83 on an Android phone, and 43.0.2357.130 for Windows), the dots are visible. In older versions of Chrome (43.0.2357.130 for Mac, for example) and in Safari and Firefox the dots are not visible. Has anyone else encountered a similar issue? Any help will be appreciated.
Here is a working example in a jsfiddle.
Here is the HTML:
<div id="mainContainer">
<div id="bottomLeftPosition">
<svg><path class="pathBottomLeft framePath" d="M127.504,105.451
c1.394-0.461,0.629-2.404,0.735-3.859c0.047-0.719,0.826-1.225,0.368-2.021c-0.338-0.598-1.333-0.398-2.39-0.735
c-1.424-0.442-1.931-1.087-3.493-0.735c-2.143,0.475-7.396,4.611-8.453,6.25c-0.674,1.041-1.501,3.322-1.471,4.227
c0.045,1.363,2.036,4.655,2.573,5.146c2.036,1.852,6.769,2.986,10.107,2.389c1.715-0.307,2.97-1.578,4.593-1.654
c2.084-2.389,4.381-4.564,6.066-7.352l0.887-5.713l-1.071-5.314c-1.286-3.615-4.104-5.696-6.064-8.637
c-1.579-0.965-3.461-1.058-5.147-1.84c-0.75-0.352-1.254-1.148-2.021-1.47c-1.775-0.735-3.98-0.245-5.696-1.47
c-7.427-0.858-13.187,0.994-19.665,2.021c-14.793,5.359-29.726,12.865-42.453,20.766c-1.011,0.628-2.022,1.426-3.125,2.021
c-1.93,1.043-3.293,1.533-5.697,2.389c-1.256,0.445-2.39,1.38-3.492,1.654c-4.642,1.166-9.604-1.285-12.498-4.225
c-0.934-2.758-2.573-5.451-2.389-9.926c0.077-1.852,1.01-3.538,0.551-5.329c3.186-8.179,6.616-16.249,11.578-23.708
c0.415-0.627,1.226-1.041,1.655-1.654c0.643-0.934,0.872-2.266,1.47-3.307c0.551-0.98,1.547-1.7,2.022-2.573
c1.592-2.911,2.389-7.168,2.94-10.66c0.245-1.547-0.261-2.925-0.368-4.595c-0.092-1.409,0.23-2.879,0.185-4.411
c-0.092-3.768-0.766-8.071-1.287-11.946c-0.291-2.145-0.26-4.84-1.103-6.8c-1.057-2.466-3.277-3.538-4.594-6.065
c-2.251-0.75-4.519-1.485-6.433-2.572L29.73,14.11c-2.634,0.214-3.967,1.777-6.065,2.94C21,20.665,13.879,30.804,18.152,35.98
c2.205,2.665,4.456,6.249,8.821,4.228c0.583-2.144,4.028-3.905,5.513-6.616c0.199-0.368,0.153-1.011,0.368-1.471
c0.367-0.75,0.995-1.24,1.103-1.837c0.062-0.367-0.336-3.89-0.551-4.595c-0.75-2.542-3.706-2.036-4.594,0"/></svg>
</div>
<div id="topLeftPosition">
<svg><path class="pathTopLeft framePath" d=
"M29.638,109.531c1.792-2.664,3.92-8.469,1.838-12.13c-0.75-0.123-1.087-0.55-1.654-0.919c-1.118-0.703-1.731-1.071-2.94-1.654
c-1.348-0.643-0.919-0.489-2.573-0.551c-1.976-0.062-2.665,0.443-4.043,1.654c-2.604,2.297-5.146,5.514-5.513,9.373
c-0.705,7.458,4.717,12.42,9.924,14.702c0,0,2.281,0.2,2.343,0.214c0.138,0,2.251-0.582,2.251-0.582
c1.93-0.918,3.094-2.449,4.595-3.857c1.057-0.981,2.22-1.303,3.124-2.572c0.521-0.736,1.011-1.824,1.654-2.758
c0.583-0.857,1.486-1.73,1.838-2.389c0.384-0.719,0.245-1.593,0.552-2.572c0.275-0.857,1.042-1.762,1.286-2.573
c0.903-2.972,0.659-7.366,0.552-10.292c-0.261-7.488-2.405-13.509-4.778-19.481c-0.751-1.915-2.083-3.476-2.941-5.33
c-0.628-1.362-1.087-2.817-1.838-4.226c-0.95-1.792-2.359-2.772-2.573-5.146c-2.374-3.553-3.584-7.903-4.962-12.129
c-0.475-1.456-1.287-3.064-1.471-5.513c-0.367-4.992,1.976-9.327,3.86-13.417c1.271-2.772,2.71-5.252,4.41-6.799
c5.989-5.438,16.847-8.333,26.648-8.088c4.794,0.123,9.909,0.581,14.152,2.021c1.486,0.506,3.032,1.286,4.595,1.837
c1.593,0.552,3.384,0.98,4.779,1.654c1.838,0.889,3.553,2.39,5.329,3.492c3.095,1.915,5.667,3.048,8.086,5.331
c2.543,2.404,4.442,5.482,6.802,7.902c2.557,2.635,5.713,4.012,8.453,6.249c2.863,0.812,5.729,1.624,7.902,3.124
c11.579,2.635,21.748-2.113,25.729-9.924c0,0,1.47-9.266,0.919-11.548c0.046-0.72-1.103-4.809-1.103-4.809
c-1.424-2.374-2.895-4.028-5.022-5.698c-0.949-0.827-3.568-2.803-6.785-1.179c-2.955,2.144-5.851,7.596-2.298,11.026
c2.358,2.268,6.311,1.731,9.558,2.206"/></svg>
</div>
<div id="topRightPosition">
<svg><path class="pathTopRight framePath" d="M25.065,32.641
c0,0,4.334-2.696,4.518-2.833c2.696-1.869,5.728-2.864,6.065-6.616c-0.995-7.259-8.883-7.32-12.772-4.15
c-2.849,2.312-5.391,7.473-5.391,12.512c0,2.021-0.015,5.223,0.919,7.352c0.674,1.532,2.925,3.706,4.962,4.411
c0.719,0.246,1.776,0.124,2.572,0.368c1.761,0.536,2.451,1.363,5.33,1.103c6.371-0.567,12.023-1.516,17.827-2.94
c1.257-0.307,2.052-0.842,3.309-1.287c1.593-0.582,3.385-0.582,4.963-1.103c2.894-0.965,5.773-2.375,8.637-3.492
c3.033-1.179,6.126-2.205,9.005-3.492c6.294-2.818,12.649-7.03,19.113-9.557c2.528-0.995,5.054-1.562,7.167-3.124
c0.675,0.061,1.195-0.031,1.654-0.184c4.624-2.926,12.865-3.645,19.113-3.676c1.041,0.612,2.129,1.179,3.676,1.286
c3.047,2.007,6.77,4.793,8.637,8.822c1.656,3.553,2.145,7.888,2.574,12.314c0.229,2.451-0.385,5.314-0.367,7.903
c0.107,13.768-7.704,24.688-11.763,35.653c-2.466,2.236-2.772,5.896-4.593,9.924c-0.322,0.721-0.995,1.286-1.287,2.021
c-2.344,5.881-3.83,15.408-0.185,20.217c1.685,2.221,7.169,4.977,10.661,3.859c2.268-0.72,3.521-2.543,5.145-4.41
c0.245-6.005-2.387-9.129-5.879-11.396c-1.104,0.309-1.93-0.211-2.757,0.369c-0.49,0.703-0.124,1.393-0.185,2.389"/></svg>
</div>
<div id="bottomRightPosition">
<svg><path class="pathBottomRight framePath" d="
M133.236,18.858c0.106,1.517-3.018,6.448,0.184,7.168c1.256,0.275,3.782-1.087,4.962-1.838c2.757-1.761,4.228-5.773,4.779-8.271
c-0.981-2.189-2.282-4.793-4.595-5.88c-3.645-1.716-8.867-0.153-11.027,2.205c-2.45,2.68-4.41,7.979-4.778,13.049
c-0.291,4.088,0.95,6.371,3.308,8.454c1.961,1.746,4.61,2.788,6.618,4.595c0.153,0.138,0.353,0.521,0.55,0.735
c2.007,2.159,3.507,4.441,4.963,7.536c0.658,1.393,1.026,5.575,1.471,7.657c0.628,2.91,1.623,6.264,1.838,9.005
c0.904,11.777-0.154,23.968-6.8,31.611c-1.731,1.163-3.309,2.647-5.147,3.858c-1.699,1.103-3.415,2.634-5.329,3.492
c-0.873,0.382-2.006,0.382-2.94,0.733c-5.238,1.962-11.104,2.59-17.828,3.31c-4.762,0.521-8.898,0.949-14.52,1.103
c-4.746,0.123-9.158,1.103-12.864-0.184c-3.69-0.153-6.708-2.129-10.475-2.205c-2.328-1.348-5.452-2.465-8.086-2.94
c-1.731-1.808-5.299-1.257-7.167-2.206c-0.888-0.153-0.659,0.812-1.654,0.552c-1.501-0.644-3.033-1.257-4.779-1.654
c-0.627-0.169-0.536-1.058-1.103-1.286c-2.971-0.904-4.961-3.554-7.718-4.596c-0.384-0.137-0.98,0.123-1.471,0
c-0.949-0.229-1.898-1.147-2.756-1.285c-9.802-1.517-18.486,8.055-16.54,17.09c0.321,1.486,0.413,3.493,2.052,5.897
c3.752,4.364,7.918,1.716,10.66-1.286c1.47-1.609,3.614-8.729,0.276-9.006c-2.85-0.23-5.391,3.338-5.882,3.491"/></svg>
</div>
<div id="border"></div>
</div>
And the CSS:
body {
margin:0;
padding:0;
}
#mainContainer{
position: relative;
width: 300px;
height: 600px;
overflow: hidden;
background-color: #fff;
}
#border{
position:absolute;
width:298px;
height:598px;
border:solid 1px #000;
}
#bottomLeftPosition{
position:absolute;
left:5px;
top:231px;
}
#topLeftPosition{
position:absolute;
left:9px;
top:123px;
}
#topRightPosition{
position:absolute;
left:140px;
top:116px;
}
#bottomRightPosition{
position:absolute;
left:130px;
top:226px;
}
.framePath {
width:160px;
height:130px;
fill:none;
stroke:#000;
stroke-width:3;
stroke-linecap:round;
stroke-miterlimit:10;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
}
.pathBottomLeft {
animation: dash 1.7s linear 1.5s forwards;
-webkit-animation: dash 1.7s linear 1.5s forwards;
-moz-animation: dash 1.7s linear 1.5s forwards;
}
.pathTopLeft {
animation: dash 1.7s linear 2.2s forwards;
-webkit-animation: dash 1.7s linear 2.2s forwards;
-moz-animation: dash 1.7s linear 2.2s forwards;
}
.pathTopRight {
animation: dash 1.7s linear 2.9s forwards;
-webkit-animation: dash 1.7s linear 2.9s forwards;
-moz-animation: dash 1.7s linear 2.9s forwards;
}
.pathBottomRight {
animation: dash 1.7s linear 3.5s forwards;
-webkit-animation: dash 1.7s linear 3.5s forwards;
-moz-animation: dash 1.7s linear 3.5s forwards;
}
#keyframes dash {
0% {
stroke-dashoffset: 1000;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes dash {
0% {
stroke-dashoffset: 1000;
}
100% {
stroke-dashoffset: 0;
}
}
#-moz-keyframes dash {
0% {
stroke-dashoffset: 1000;
}
100% {
stroke-dashoffset: 0;
}
}
I don't necessarily think this is a bug, but it should certainly be fixed. Because there is a line with what seems to be a length of 0, you'd think it'd be invisible. But in these builds of Chrome, a line with a length of 0 and a positive stroke-width, will render. Just like how the browser will still render a div when it has been given a height of 0 but also a border thicker than 0.
If you want to solve the issue, You can add something like visibility: hidden; or opacity: 0; to .framePath, and then add the opposite to the animation (at 0% and 100%)

Multiple keyframe animations not working in safari

I'm working with HTML5 banner having a lot of CSS3 animation. To make reusable keyframe animation I'm using multiple animation on single element. It's working perfectly except safari.
CSS:
.text1 {
-webkit-animation: fadeOutRight 1s 3s forwards;
animation: fadeOutRight 1s 3s forwards;
}
.text2 {
-webkit-animation: fadeInLeft 1s 4s both, fadeOutRight 1s 7s forwards;
animation: fadeInLeft 1s 4s both, fadeOutRight 1s 7s forwards;
}
.text3 {
-webkit-animation: fadeInLeft 1s 8s both;
animation: fadeInLeft 1s 8s both;
}
/* fadeInLeft */
#-webkit-keyframes fadeInLeft {
0% { -webkit-transform: translateX(-100px); opacity: 0; }
100% { -webkit-transform: translateX(0px); opacity: 1; }
}
#keyframes fadeInLeft {
0% { transform: translateX(-100px); opacity: 0; }
100% { transform: translateX(0px); opacity: 1; }
}
/* fadeOutRight */
#-webkit-keyframes fadeOutRight {
0% { -webkit-transform: translateX(0px); opacity: 1; }
100% { -webkit-transform: translateX(100px); opacity: 0; }
}
#keyframes fadeOutRight {
0% { transform: translateX(0px); opacity: 1; }
100% { transform: translateX(100px); opacity: 0; }
}
jsfiddle link
Workable solutions:
Wrap the element with another/more element & add single animation to each element. This solution needs extra styling for wrapper element.
Merge multiple animation into one & this solution increase the complexity of the keyframes rule and it's not easily maintainable for complex animation.
According to accepted answer of another stackOverflow post –
You cannot animate same attribute more than once, on a same element, the last one will overwrite other.
It’s only true for safari in my case & first animation is only running not
second one. If I don’t animate same property on multiple animation
then it’s also fine for safari(jsfiddle). This one is not
suitable for me because I will need to animate same property in
multiple animations.
Note:
Although I'm using multiple animation on same element but I'm not animating at same time, there is delay between each animation.
Question:
Is it possible to use multiple CSS3 animation on same element regardless of animating property?
For some reason, Safari does not read trough the shorthand method for describing the animation, for example:
animation: test 1s 2s 3 alternate backwards
It needs to be described more detailed with its separate properties listed:
.class{
animation-name: bounce;
animation-duration: 4s;
animation-iteration-count: 10;
animation-direction: alternate;
animation-timing-function: ease-out;
animation-fill-mode: forwards;
animation-delay: 2s;
}

Accelerate image spinning on hover

I got an image
<div class="spin-image">
<img src="images/color-wheel.png" alt="" />
</div>
and its corresponding css
.spin-image {
-webkit-animation:spin 10s linear infinite;
-moz-animation:spin 10s linear infinite;
animation:spin 10s linear infinite;
-webkit-transition-duration: 2s; /* Safari */
transition-duration: 2s;
}
.spin-image:hover {
-webkit-animation:spin 2s linear infinite;
-moz-animation:spin 2s linear infinite;
animation:spin 2s linear infinite;
}
#-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
#-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
#keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
What I'm trying to do is to accelerate the image spinning on hover. The animation works, but the transition does not.
If you realise, this is like the animation and the hover animation are two different ones, and they reset to their virtual state of rotation in case they were running all the time you were or weren't hovering.
Unfortunatly, it is not posible to animate the transition between 2 different animation-durations.
Yet if you really really need a solution for this, you could program the animation using transition and a javascript interval that resets the positions for every turn. This way yo can reset the property and the duration of the transition at any time with javascript.
I made you a pen: http://codepen.io/vandervals/pen/aONmVL
This is the css you need:
.spin-image img{
transition: transform 2s linear;
transform: rotate(0deg);
}
.spin-image img.hover{
transition: transform 1s linear;
}
And the JS:
var vel = 2000;
var degs = 0;
var cat = document.querySelector("img");
function repeat(){
if(vel == 1000){
cat.classList.add("hover");
console.log("hover")
}else{
cat.classList.remove("hover");
console.log("nohover")
}
degs+=360;
cat.style.transform = "rotate("+degs+"deg)";
setTimeout(repeat, vel);
}
repeat();
document.querySelector("img").addEventListener("mouseenter",hovering);
function hovering(){
vel = 1000;
}
document.querySelector("img").addEventListener("mouseleave",nohovering);
function nohovering(){
vel = 2000;
}

CSS animation tricky bug in Chrome

I have the following CSS:
#-webkit-keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
#-webkit-keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
.intro-text-0 {
opacity: 0;
-webkit-animation: fade-in 1s linear 1s,
fade-out 1s linear 3s;
-webkit-animation-fill-mode: forwards;
}
.intro-text-1 {
opacity: 0;
-webkit-animation: fade-in 1s linear 2s,
fade-out 1s linear 4s;
-webkit-animation-fill-mode: forwards;
}
And the simple HTML code:
<div class="intro-text-0">Hello</div>
<div class="intro-text-1">Holla</div>
When I run it, "Hello" appear in 1 second and in 3 seconds instead of fading out for 1 second, it fades out instantly. Here it is on JSFiddle: http://jsfiddle.net/3er6y0df/
I tried switching it to this:
.intro-text-0 {
opacity: 0;
-webkit-animation: fade-in 1s linear 2s,
fade-out 1s linear 4s;
-webkit-animation-fill-mode: forwards;
}
And it works perfectly.
I must mention, that this bug appeared only in Chrome (Version 37.0.2062.120 Built on Debian 7.6, running on Debian 7.7 (281580) (64-bit)), I check it out in Firefox and IE11 and there is no problem there.
Not really a bugfix though it could be a alternative.
Instead of animating a element with keyframes + animation on the elements itself why not put it all in the keyframe animation?
#keyframes AnimateMe {
0% { opacity:0%; }
80% { opacity:100%; }
100% { opacity:0%; }
}
I have experimented a bit and found a much simpler solution:
-webkit-animation: fade-in 1s linear 1001ms,
fade-out 1s linear 3s;
-webkit-animation-fill-mode: forwards;
Using 1001ms instead 1s (=1000ms) will not be noticed by a regular human eye :)