body {
margin: 0;
background-color: lightgray;
}
#block{
-moz-animation-play-state: paused;
/* duration set to required length in seconds */
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
/* name of keyframe animation sequence */
-webkit-animation-name: slidedown;
-moz-animation-name: slidedown;
/* fill-mode can be set to backwards or both in order to prevent display of contents before animation has begun */
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
/* position and size at the end of the animation */
margin-top: 25%;
padding-bottom: 100%;
/* other attributes that will be true throughout sequence and following it */
z-index:-1;
background-color: black;
}
#heading {
/* duration set to required length in seconds */
-webkit-animation-duration: 6s;
-moz-animation-duration: 6s;
/* name of keyframe animation sequence */
-webkit-animation-name: slidein;
-moz-animation-name: slidein;
/* position at the end of the animation */
margin-left: 50%;
/* other attributes that will be true throughout sequence and following it */
background-color: lightgray;
padding: 10px;
padding-top: 400px;
color: white;
opacity: 0.6;
}
/* beginning of named keyframes corresponding with those named above */
/* assign a name to the keyframes sequence named slidein */
@-webkit-keyframes slidein {
/* set starting properties for animation sequence */
from {
margin-left: 100%;
width: 150%
}
/* set ending properties for animation sequence */
to {
margin-left: 50%;
width: 150%;
}
}
@-moz-keyframes slidein {
/* set starting properties for animation sequence */
from {
margin-left: 100%;
width: 150%
}
/* set ending properties for animation sequence */
to {
margin-left: 50%;
width: 150%;
}
}
/* assign a name to the keyframes sequence called slidedown */
@-webkit-keyframes slidedown {
/* set starting...
JavaScript
var e;
function setup() {
e = document.getElementById('heading'); e.addEventListener("webkitAnimationStart", listener, false);
e.addEventListener("animationstart", listener, false);
e.addEventListener("webkitAnimationEnd", listener, false);
e.addEventListener("animationend", listener, false);
}
function listener(e) {
switch(e.type) {
case "webkitAnimationStart":
document.getElementById('block').style.webkitAnimationPlayState='paused';
break;
case "animationstart":
document.getElementById('block').style.MozAnimationPlayState='paused';
break;
case "webkitAnimationEnd":
document.getElementById('block').style.webkitAnimationPlayState='running';
break;
case "animationend":
document.getElementById('block').style.MozAnimationPlayState='running';
break;
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.