I'm working on a project where multiple div's are loaded with a small animation, but as you can see in the fiddle down, they're carrying all at once. Any idea how do they carry one after another with a delay of 0.1 s?
http://jsfiddle.net/HaQmN/38/
Thanks
.animated {
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-ms-animation-duration: 1s;
-o-animation-duration: 1s;
animation-duration: 1s;
}
.animated.hinge {
-webkit-animation-duration: 2s;
-moz-animation-duration: 2s;
-ms-animation-duration: 2s;
-o-animation-duration: 2s;
animation-duration: 2s;
}
#-webkit-keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translateY(20px);
}
100% {
opacity: 1;
-webkit-transform: translateY(0);
}
}
#-moz-keyframes fadeInUp {
0% {
opacity: 0;
-moz-transform: translateY(20px);
}
100% {
opacity: 1;
-moz-transform: translateY(0);
}
}
#-o-keyframes fadeInUp {
0% {
opacity: 0;
-o-transform: translateY(20px);
}
100% {
opacity: 1;
-o-transform: translateY(0);
}
}
#keyframes fadeInUp {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.fadeInUp {
-webkit-animation-name: fadeInUp;
-moz-animation-name: fadeInUp;
-o-animation-name: fadeInUp;
animation-name: fadeInUp;
}
.example {
display: inline-block;
width:48%;
height:100px;
background:orange;
margin: 1% 1%;
}
<div class="animated fadeInUp example">Hello World</div>
You can delay animation with animation-delay property like bellow.
.animated:nth-child(1){
-webkit-animation-delay: 0.1s;
}
.animated:nth-child(2){
-webkit-animation-delay: 0.2s;
background-color: red;
}
.animated:nth-child(3){
-webkit-animation-delay: 0.3s;
animation-delay: 1.5s;
}
.animated:nth-child(4){
-webkit-animation-delay: 0.4s;
animation-delay: 1.5s;
}
.animated:nth-child(5){
-webkit-animation-delay: 0.5s;
animation-delay: 1.5s;
}
.animated:nth-child(6){
-webkit-animation-delay: 0.6s;
animation-delay: 1.5s;
}
But that is a lot of CSS and doest not suite if you have dynamic number of Divs. so you javascript to add delay property to you divs one by one.
Related
Css animation doesn't work in internet explorer, version 11 for sure.
All the other browsers animate it perfectly good. Here is a website: http://susannahpryce.esy.es
I checked through firebug in IE, it reads the code with no erroers, so i don't know why it doesn't work, i'm using IE 11.
And here is my code
body .main .header-box {
background-color: #fff;
height: 500px;
width: 100%;
float: left; }
body .main .header-box .slide-area {
margin: 0 9%; }
body .main .header-box .slide-area #pic1 {
position: absolute;
z-index: 5;
-webkit-animation-duration: 60s;
-webkit-animation-delay: 10s;
-webkit-transition-timing-function: ease;
-webkit-animation-name: slide-fade;
-webkit-animation-iteration-count: infinite;
-ms-animation-duration: 60s;
-ms-animation-delay: 10s;
-ms-transition-timing-function: ease;
-ms-animation-name: slide-fade;
-ms-animation-iteration-count: infinite;
-moz-animation-duration: 60s;
-moz-animation-delay: 10s;
-moz-transition-timing-function: ease;
-moz-animation-name: slide-fade;
-moz-animation-iteration-count: infinite; }
body .main .header-box .slide-area #pic2 {
position: absolute;
z-index: 4;
-webkit-animation-duration: 60s;
-webkit-animation-delay: 20s;
-webkit-transition-timing-function: ease;
-webkit-animation-name: slide-fade;
-webkit-animation-iteration-count: infinite;
-ms-animation-duration: 60s;
-ms-animation-delay: 20s;
-ms-transition-timing-function: ease;
-ms-animation-name: slide-fade;
-ms-animation-iteration-count: infinite;
-moz-animation-duration: 60s;
-moz-animation-delay: 20s;
-moz-transition-timing-function: ease;
-moz-animation-name: slide-fade;
-moz-animation-iteration-count: infinite; }
body .main .header-box .slide-area #pic3 {
position: absolute;
z-index: 3;
-webkit-animation-duration: 60s;
-webkit-animation-delay: 30s;
-webkit-transition-timing-function: ease;
-webkit-animation-name: slide-fade;
-webkit-animation-iteration-count: infinite;
-ms-animation-duration: 60s;
-ms-animation-delay: 30s;
-ms-transition-timing-function: ease;
-ms-animation-name: slide-fade;
-ms-animation-iteration-count: infinite;
-moz-animation-duration: 60s;
-moz-animation-delay: 30s;
-moz-transition-timing-function: ease;
-moz-animation-name: slide-fade;
-moz-animation-iteration-count: infinite; }
body .main .header-box .slide-area #pic4 {
position: relative;
z-index: 2; }
#-webkit-keyframes slide-fade {
0% {
opacity: 1; }
5% {
opacity: 0; }
50% {
opacity: 0; }
55% {
opacity: 1; }
100% {
opacity: 1; } }
#-ms-keyframes slide-fade {
0% {
opacity: 1; }
5% {
opacity: 0; }
50% {
opacity: 0; }
55% {
opacity: 1; }
100% {
opacity: 1; } }
#-moz-keyframes slide-fade {
0% {
opacity: 1; }
5% {
opacity: 0; }
50% {
opacity: 0; }
55% {
opacity: 1; }
100% {
opacity: 1; } }
Take the animation css out of the media query. I did a simple copy and paste and edited the css a little bit to make it work. As stated here http://caniuse.com/#search=css-animation (thanks to Paulie_D) in the known issues tab
IE10 and IE11 do not support CSS animations inside media queries.
http://jsfiddle.net/xmfj0tk7/
<div class="header-box">
<div class="slide-area">
<img id="pic1" src="http://susannahpryce.esy.es/wp-content/themes/sue/pics/hq-1-optimized.jpg" />
<img id="pic2" src="http://susannahpryce.esy.es/wp-content/themes/sue/pics/hq-2-optimized.jpg" />
<img id="pic3" src="http://susannahpryce.esy.es/wp-content/themes/sue/pics/hq-3-optimized.jpg" />
<img id="pic4" src="http://susannahpryce.esy.es/wp-content/themes/sue/pics/hq-4-optimized.jpg" />
</div>
<div class="slide-area_480">
</div>
<div class="slide-area_640">
</div>
</div>
You should also put the normal css rules in your file, as in without prefixes. Modern browsers should not need the prefixes and in the future, the prefixes should go away at some point... for this animation stuff anyway
historically IE doesn't apply several styles to elements that don't
"have layout."
see: http://www.satzansatz.de/cssd/onhavinglayout.html
Here is a question that was asked regarding opacity in IE.
Hey i'm trying to make a fancy border animation around some words and it's working well in Firefox & Chrome but not in IE. I was wondering if somebody knew why it isnt working in IE? The animation won't initiate.
My HTML
<div class="box">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<line class="top" x1="-146" y2="0" x2="400" y2="0" />
<line class="left" x1="0" y1="60" x2="0" y2="-30" />
<line class="bottom" x1="292" y1="30" x2="-264" y2="30" />
<line class="right" x1="146" y1="-30" x2="146" y2="60" />
</svg>
<h2>My Words</h2>
My CSS
h2 {
font-family:'Source Sans Pro', sans-serif;
font-size: 1em;
text-align: center;
line-height: 30px;
color: black;
letter-spacing: 0.07em;
}
.box {
width: 146px;
height: 30px;
position: relative;
margin: 0 auto 15px auto;
color: #2c3e50;
padding-bottom: 0.05em;
padding-left: 1px;
padding-right: 0.05em;
}
.box svg {
position: absolute;
top: 0;
left: 0;
overflow:hidden;
}
.box svg line {
stroke-width: 3;
stroke: #000;
fill: none;
}
.box svg line.top, .box svg line.bottom, .box svg line.left, .box svg line.right {
-webkit-animation-delay: 0.25s !important;
-moz-animation-delay: 0.25s !important;
-ms-animation-delay: 0.25s !important;
-o-animation-delay: 0.25s !important;
animation-delay: 0.25s !important;
}
.box svg line.top {
stroke-dasharray: 146;
-webkit-animation: Topline 1s;
-moz-animation: Topline 1s;
-ms-animation: Topline 1s;
-o-animation: Topline 1s;
animation: Topline 1s;
-webkit-animation-fill-mode: forwards;
-moz-animation-fill-mode: forwards;
-o-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.box svg line.bottom {
stroke-dasharray: 146;
-webkit-animation: Bottomline 1s;
-moz-animation: Bottomline 1s;
-ms-animation: Bottomline 1s;
-o-animation: Bottomline 1s;
animation: Bottomline 1s;
-webkit-animation-fill-mode: forwards;
-moz-animation-fill-mode: forwards;
-o-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.box svg line.left {
stroke-dasharray: 30;
-webkit-animation: Leftline 1s;
-moz-animation: Leftline 1s;
-ms-animation: Leftline 1s;
-o-animation: Leftline 1s;
animation: Leftline 1s;
-webkit-animation-fill-mode: forwards;
-moz-animation-fill-mode: forwards;
-o-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.box svg line.right {
stroke-dasharray: 30;
-webkit-animation: Rightline 1s;
-moz-animation: Rightline 1s;
-ms-animation: Rightline 1s;
-o-animation: Rightline 1s;
animation: Rightline 1s;
-webkit-animation-fill-mode: forwards;
-moz-animation-fill-mode: forwards;
-o-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
#-webkit-keyframes Topline {
100% {
-webkit-transform: translateX(-146px);
}
}
#keyframes Topline {
100% {
-moz-transform: translateX(-146px);
-ms-transform: translateX(-146px);
-o-transform: translateX(-146px);
transform: translateX(-146px);
}
}
#-webkit-keyframes Bottomline {
100% {
-webkit-transform: translateX(146px);
}
}
#keyframes Bottomline {
100% {
-moz-transform: translateX(146px);
-ms-transform: translateX(146px);
-o-transform: translateX(146px);
transform: translateX(146px);
}
}
#-webkit-keyframes Leftline {
100% {
-webkit-transform: translateY(30px);
}
}
#keyframes Leftline {
100% {
-moz-transform: translateY(30px);
-ms-transform: translateY(30px);
-o-transform: translateY(30px);
transform: translateY(30px);
}
}
#-webkit-keyframes Rightline {
100% {
-webkit-transform: translateY(-30px);
}
}
#keyframes Rightline {
100% {
-moz-transform: translateY(-30px);
-ms-transform: translateY(-30px);
-o-transform: translateY(-30px);
transform: translateY(-30px);
}
}
Here is a setup of what i'm trying to accomplish : Fiddle
And this is the demo that I roughly followed.
Here it is on JS fiddle
http://jsfiddle.net/VR7AN/
I have made a simple animation with the basic principles of this guide: http://tympanus.net/codrops/2012/01/02/fullscreen-background-image-slideshow-with-css3/
The animation runs perfectly the first time, but when it loops it turns grey and only cycles through some of the images. I can't figure out why the loop would work but not the same as the first time.
Here's my css:
#fadethru > img {
position: absolute;
color: transparent;
top: 0px;
left: 0px;
opacity: 0;
z-index: 0;
display: block;
-webkit-animation: imageAnimation 4.5s linear infinite 0s;
-moz-animation: imageAnimation 4.5s linear infinite 0s;
-o-animation: imageAnimation 4.5s linear infinite 0s;
-ms-animation: imageAnimation 4.5s linear infinite 0s;
animation: imageAnimation 4.5s linear infinite 0s;
animation-iteration-count: infinite;
}
#fadethru > img:nth-child(1) {
-webkit-animation-delay: 0.5s;
-moz-animation-delay: 0.5s;
-o-animation-delay: 0.5s;
-ms-animation-delay: 0.5s;
animation-delay: 0.5s;
}
#fadethru > img:nth-child(2) {
-webkit-animation-delay: 1s;
-moz-animation-delay: 1s;
-o-animation-delay: 1s;
-ms-animation-delay: 1s;
animation-delay: 1s;
}
#fadethru > img:nth-child(3) {
-webkit-animation-delay: 1.5s;
-moz-animation-delay: 1.5s;
-o-animation-delay: 1.5s;
-ms-animation-delay: 1.5s;
animation-delay: 1.5s;
}
#fadethru > img:nth-child(4) {
-webkit-animation-delay: 2s;
-moz-animation-delay: 2s;
-o-animation-delay: 2s;
-ms-animation-delay: 2s;
animation-delay: 2s;
}
#fadethru > img:nth-child(5) {
-webkit-animation-delay: 2.5s;
-moz-animation-delay: 2.5s;
-o-animation-delay: 2.5s;
-ms-animation-delay: 2.5s;
animation-delay: 2.5s;
}
#fadethru > img:nth-child(6) {
-webkit-animation-delay: 3s;
-moz-animation-delay: 3s;
-o-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
}
#fadethru > img:nth-child(7) {
-webkit-animation-delay: 3.5s;
-moz-animation-delay: 3.5s;
-o-animation-delay: 3.5s;
-ms-animation-delay: 3.5s;
animation-delay: 3.5s;
}
#fadethru > img:nth-child(8) {
-webkit-animation-delay: 4s;
-moz-animation-delay: 4s;
-o-animation-delay: 4s;
-ms-animation-delay: 4s;
animation-delay: 4s;
}
#fadethru > img:nth-child(9) {
-webkit-animation-delay: 4.5s;
-moz-animation-delay: 4.5s;
-o-animation-delay: 4.5s;
-ms-animation-delay: 4.5s;
animation-delay: 4.5s;
}
#-webkit-keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
15% { opacity: 1; animation-timing-function: ease-out; }
50% { opacity: 1 }
75% { opacity: 0 }
100% { opacity: 0 }
}
#-moz-keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
15% { opacity: 1; animation-timing-function: ease-out; }
50% { opacity: 1 }
75% { opacity: 0 }
100% { opacity: 0 }
}
#-o-keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
15% { opacity: 1; animation-timing-function: ease-out; }
50% { opacity: 1 }
75% { opacity: 0 }
100% { opacity: 0 }
}
#-ms-keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
15% { opacity: 1; animation-timing-function: ease-out; }
50% { opacity: 1 }
75% { opacity: 0 }
100% { opacity: 0 }
}
#keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
15% { opacity: 1; animation-timing-function: ease-out; }
50% { opacity: 1; }
75% { opacity: 0; }
100% { opacity: 0 }
}
and the HTML:
<div id="fadethru">
<img src="img/redjewel.png" id="red" alt="red jewel">
<img src="img/orangejewel.png" id="orange" alt="orange jewel">
<img src="img/yellowjewel.png" id="yellow" alt="yellow jewel">
<img src="img/grassjewel.png" id="grass" alt="green jewel">
<img src="img/greenjewel.png" id="green" alt="turquois jewel">
<img src="img/bluejewel.png" id="blue" alt="blue jewel">
<img src="img/indigojewel.png" id="indigo" alt="indigo jewel">
<img src="img/purplejewel.png" id="purple" alt="purple jewel">
<img src="img/pinkjewel.png" id="pink" alt="pink jewel">
</div>
You need to display each item only for the portion of the time of the total loop it takes up. So 9 displays / 100 percent = 11.11 percent of total loop time per element.
You have the elements displaying from 15-50% of the loop, so when it starts to repeat, some elements are covering others, but that doesn't work properly, so through that error you are seeing grey.
I did mine as 0-14%, lazily, and also only for chrome (which I use) so I didn't have to type all that code! But it should fix your issue:
#fadethru > img {
opacity:0;
position:absolute;
top:0; left:0;
-webkit-animation: imageAnimation 4.5s linear infinite 0s;
}
and
#-webkit-keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
8% { opacity: 1; animation-timing-function: ease-out; }
9% { opacity: 1 }
14% { opacity: 0 }
100% { opacity: 0 }
}
Playing around with CSS 3 animations but for some reasons, all animations return to their original state after execution.
In this case I'd like the image to remain at scale(1) after animation and my text to oly appear after img animation but stay afterward.
.expanding-spinning {
-webkit-transform: scale(.4);
-webkit-transition-timing-function: ease-out;
-webkit-transition-duration: 500ms;
animation-duration: 500ms;
}
.expanding-spinning {
-webkit-animation: spin2 1.4s ease-in-out alternate;
animation: spin2 1.4s ease-in-out alternate;
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
#-webkit-keyframes spin2 {
0% { -webkit-transform: rotate(0deg) scale(.4);}
100% { -webkit-transform: rotate(360deg) scale(1);}
}
#-keyframes spin2 {
0% { transform: rotate(0deg) scale(.4);}
100% { transform: rotate(360deg) scale(1);}
}
#-webkit-keyframes fadeInFromNone {
0% {
display:none;
opacity: 0;
}
100% {
display: block;
opacity: 1;
}
}
.slogan {
display: block;
opacity: 1;
-webkit-animation-duration: 2s;
-webkit-animation-name: fadeInFromNone;
-webkit-animation-delay: 3.5s;
}
Fiddle code
You need to add the rule -webkit-animation-fill-mode: forwards; to your animations.
Also, regarding the text animation: Animate the visibility property instead of display property
FIDDLE
.expanding-spinning {
-webkit-animation: spin2 1.4s ease-in-out;
-moz-animation: spin2 1.4s linear normal;
-o-animation: spin2 1.4s linear;
-ms-animation: spin2 1.4s linear;
animation: spin2 1.4s ease-in-out alternate;
-webkit-animation-delay: 2s;
animation-delay: 2s;
-webkit-animation-fill-mode: forwards; /* <--- */
}
#-webkit-keyframes fadeInFromNone {
0% {
visibility:hidden;
opacity: 0;
}
100% {
visibility: visible;
opacity: 1;
}
}
.slogan {
visibility:hidden;
opacity: 1;
-webkit-animation-duration: 2s;
-webkit-animation-name: fadeInFromNone;
-webkit-animation-delay: 3.4s;
-webkit-animation-fill-mode: forwards; /* <--- */
}
See this article for a nice explanation of all the animation properties
The fill mode. If set to forwards, the last keyframe remains at the
end of the animation,
(from above link)
Is it possible to cross fade 5 images in CSS, without using java script? I have found a similar question:
css3 image crossfade (no javascript) , however, it has only the CSS code snippet; which I tried, but could not get it working. I'm new to CSS, so could not link the CSS mentioned in the above page to my following HTML:
<div id= "crossfade">
<img class = "cone" src = "1.png" alt = "png">
<img class = "ctwo" src = "2.png" alt = "png">
<img class = "cthree" src = "3.png" alt = "png">
<img class = "cfour" src = "4.png" alt = "png">
<img class = "cfive" src = "5.png" alt = "png">
</div>
This can easily be done with CSS3 if you know how many images you have.
jsFiddle: http://jsfiddle.net/hajmd/
#crossfade > img {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
opacity: 0;
z-index: 0;
-webkit-backface-visibility: hidden;
-webkit-animation: imageAnimation 30s linear infinite 0s;
-moz-animation: imageAnimation 30s linear infinite 0s;
-o-animation: imageAnimation 30s linear infinite 0s;
-ms-animation: imageAnimation 30s linear infinite 0s;
animation: imageAnimation 30s linear infinite 0s;
}
The "30s" at "-webkit-animation: imageAnimation 30s linear infinite 0s;" tells that the animation for each image will last 30 seconds in infinete number of times.
#crossfade > img:nth-child(2) {
background-image: url(../images/2.jpg);
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
}
#crossfade > img:nth-child(3) {
background-image: url(../images/3.jpg);
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-o-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
}
#crossfade > img:nth-child(4) {
background-image: url(../images/4.jpg);
-webkit-animation-delay: 18s;
-moz-animation-delay: 18s;
-o-animation-delay: 18s;
-ms-animation-delay: 18s;
animation-delay: 18s;
}
#crossfade > img:nth-child(5) {
background-image: url(../images/5.jpg);
-webkit-animation-delay: 24s;
-moz-animation-delay: 24s;
-o-animation-delay: 24s;
-ms-animation-delay: 24s;
animation-delay: 24s;
}
#-webkit-keyframes imageAnimation {
0% { opacity: 0;
-webkit-animation-timing-function: ease-in; }
8% { opacity: 1;
-webkit-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#-moz-keyframes imageAnimation {
0% { opacity: 0;
-moz-animation-timing-function: ease-in; }
8% { opacity: 1;
-moz-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#-o-keyframes imageAnimation {
0% { opacity: 0;
-o-animation-timing-function: ease-in; }
8% { opacity: 1;
-o-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#-ms-keyframes imageAnimation {
0% { opacity: 0;
-ms-animation-timing-function: ease-in; }
8% { opacity: 1;
-ms-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#keyframes imageAnimation {
0% { opacity: 0;
animation-timing-function: ease-in; }
8% { opacity: 1;
animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
The example you referenced should work for you for the example you referenced. However please note that CSS3 is not supported on all browsers (Such as IE8 and IE7) and therefore will not work in those browsers.