Hey guys I am currently building an image show (small) with css3 keyframes, and it is working, but only on firefox in some way, and I cant seem to tackle the problem :( It should work in the latest versions of chrome firefox and safari, but its currently only working in firefox.
Anyone can that can help?
Here's the css that should work in al above browsers.
#keyframes cf4FadeInOut {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
.case-image {
position:relative;
height:auto;
width:32%;
}
.case-image img {
position:absolute;
width: 100%;
height: auto;
left:0;
border: 3px solid #f8d206;
-moz-border-radius: 15px;
border-radius: 15px;
margin-left: -3px;
margin-right: -3px;
}
.case-image img {
-webkit-animation-name: cf4FadeInOut;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 8s;
-moz-animation-name: cf4FadeInOut;
-moz-animation-timing-function: ease-in-out;
-moz-animation-iteration-count: infinite;
-moz-animation-duration: 8s;
-o-animation-name: cf4FadeInOut;
-o-animation-timing-function: ease-in-out;
-o-animation-iteration-count: infinite;
-o-animation-duration: 8s;
animation-name: cf4FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 8s;
}
.case-image img:nth-of-type(1) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
animation-delay: 6s;
}
.case-image img:nth-of-type(2) {
-webkit-animation-delay: 4s;
-moz-animation-delay: 4s;
-o-animation-delay: 4s;
animation-delay: 4s;
}
.case-image img:nth-of-type(3) {
-webkit-animation-delay: 2s;
-moz-animation-delay: 2s;
-o-animation-delay: 2s;
animation-delay: 2s;
}
.case-image img:nth-of-type(4) {
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
-o-animation-delay: 0;
animation-delay: 0;
}
You need to include the vendor prefixes for the keyframes. See here for an example: http://jsfiddle.net/tjfogarty/Gzxkq/
#keyframes pulse {
0% { width: 40px; height: 40px; }
100% { width: 50px; height: 50px; }
}
#-webkit-keyframes pulse {
0% { width: 40px; height: 40px; }
100% { width: 50px; height: 50px; }
}
#-moz-keyframes pulse {
0% { width: 40px; height: 40px; }
100% { width: 50px; height: 50px; }
}
Etc...
You can also use something like this: http://leaverou.github.com/prefixfree/ to take care of it for you.
Related
I found a cool, very simple text animation on a website that I would like to rebuild. Here is the link (the animation is in the footer of the page): http://www.motherbird.com.au/process/
I'm not familiar with CSS animations yet, but I've managed that so far:
.animated{
display: inline;
text-indent: 8px;
}
.animated span{
animation: topToBottom 5s infinite 0s;
-ms-animation: topToBottom 5s infinite 0s;
-webkit-animation: topToBottom 5s infinite 0s;
color: red;
opacity: 0;
overflow: hidden;
position: absolute;
}
.animated span:nth-child(2){
animation-delay: 1s;
-ms-animation-delay: 1s;
-webkit-animation-delay: 1s;
}
.animated span:nth-child(3){
animation-delay: 2s;
-ms-animation-delay: 2s;
-webkit-animation-delay: 2s;
}
.animated span:nth-child(4){
animation-delay: 3s;
-ms-animation-delay: 3s;
-webkit-animation-delay: 3s;
}
.animated span:nth-child(5){
animation-delay: 4s;
-ms-animation-delay: 4s;
-webkit-animation-delay: 4s;
}
#-webkit-keyframes topToBottom{
0% { opacity: 0; }
25% { opacity: 0; }
50% { opacity: 0; }
75% { opacity: 0; }
100% { opacity: 1; }
}
<h2>CSS Animations are
<div class="animated">
<span>cool.</span>
<span>neat.</span>
<span>awesome.</span>
<span>groovy.</span>
<span>magic.</span>
</div>
</h2>
How do I make the transition without fade?
Thanks for your help!
Another idea is to consider content of a pseudo element to change the text and you will have less of code:
.animated {
text-indent: 8px;
color:red;
}
.animated:before {
content: "cool.";
animation: topToBottom 5s infinite 0s;
}
#keyframes topToBottom {
0% {
content: "cool.";
}
25% {
content: "neat.";
}
50% {
content: "awesome.";
}
75% {
content: "groovy.";
}
100% {
content: "magic.";
}
}
<h2>CSS Animations are
<span class="animated">
</span>
</h2>
Since the animation-duration takes 5s, which represents 100% of the whole duration, and you have five spans or words, therefore each span will be visible for 1s or 20% of the time, then hidden until the end. Based on that you need to adjust the %'s inside the #keyframes to met the criteria and achieve the desired result:
.animated {
text-indent: 8px;
}
.animated span {
color: red;
opacity: 0;
overflow: hidden;
position: absolute;
-ms-animation: topToBottom 5s infinite;
-webkit-animation: topToBottom 5s infinite;
animation: topToBottom 5s infinite;
}
.animated span:nth-child(2){
-ms-animation-delay: 1s;
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
.animated span:nth-child(3){
-ms-animation-delay: 2s;
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
.animated span:nth-child(4){
-ms-animation-delay: 3s;
-webkit-animation-delay: 3s;
animation-delay: 3s;
}
.animated span:nth-child(5){
-ms-animation-delay: 4s;
-webkit-animation-delay: 4s;
animation-delay: 4s;
}
#-webkit-keyframes topToBottom {
0%, 20% {opacity: 1} /* visible for 1s */
20.01%, 100% {opacity: 0} /* hidden for 4s */
}
<h2 class="animated">
CSS Animations are
<span>cool.</span>
<span>neat.</span>
<span>awesome.</span>
<span>groovy.</span>
<span>magic.</span>
</h2>
Just .01% of a difference between the keyframes makes sure there is no fading effect.
Try visibility: hidden | visible:
.animated{
display: inline;
text-indent: 8px;
position: relative;
}
.animated span{
animation: topToBottom 5s infinite 0s;
-ms-animation: topToBottom 5s infinite 0s;
-webkit-animation: topToBottom 5s infinite 0s;
color: red;
/* display: none; */
overflow: hidden;
position: absolute;
display: inline-block;
visibility: hidden;
}
.animated span:nth-child(2){
animation-delay: 1s;
-ms-animation-delay: 1s;
-webkit-animation-delay: 1s;
}
.animated span:nth-child(3){
animation-delay: 2s;
-ms-animation-delay: 2s;
-webkit-animation-delay: 2s;
}
.animated span:nth-child(4){
animation-delay: 3s;
-ms-animation-delay: 3s;
-webkit-animation-delay: 3s;
}
.animated span:nth-child(5){
animation-delay: 4s;
-ms-animation-delay: 4s;
-webkit-animation-delay: 4s;
}
#-webkit-keyframes topToBottom{
0% { visibility: hidden; }
20% { visibility: hidden; }
40% { visibility: hidden; }
60% { visibility: hidden; }
80% { visibility: hidden; }
100% { visibility: visible; }
}
<h2>CSS Animations are
<div class="animated">
<span>cool.</span>
<span>neat.</span>
<span>awesome.</span>
<span>groovy.</span>
<span>magic.</span>
</div>
</h2>
for 10 words:
.animated{
display: inline;
text-indent: 8px;
position: relative;
}
.animated span{
animation: topToBottom 10s infinite 0s;
-ms-animation: topToBottom 10s infinite 0s;
-webkit-animation: topToBottom 10s infinite 0s;
color: red;
/* display: none; */
overflow: hidden;
position: absolute;
display: inline-block;
visibility: hidden;
}
.animated span:nth-child(2){
animation-delay: 1s;
-ms-animation-delay: 1s;
-webkit-animation-delay: 1s;
}
.animated span:nth-child(3){
animation-delay: 2s;
-ms-animation-delay: 2s;
-webkit-animation-delay: 2s;
}
.animated span:nth-child(4){
animation-delay: 3s;
-ms-animation-delay: 3s;
-webkit-animation-delay: 3s;
}
.animated span:nth-child(5){
animation-delay: 4s;
-ms-animation-delay: 4s;
-webkit-animation-delay: 4s;
}
.animated span:nth-child(6){
animation-delay: 5s;
-ms-animation-delay: 5s;
-webkit-animation-delay: 5s;
}
.animated span:nth-child(7){
animation-delay: 6s;
-ms-animation-delay: 6s;
-webkit-animation-delay: 6s;
}
.animated span:nth-child(8){
animation-delay: 7s;
-ms-animation-delay: 7s;
-webkit-animation-delay: 7s;
}
.animated span:nth-child(9){
animation-delay: 8s;
-ms-animation-delay: 8s;
-webkit-animation-delay: 8s;
}
.animated span:nth-child(10){
animation-delay: 9s;
-ms-animation-delay: 9s;
-webkit-animation-delay: 9s;
}
#-webkit-keyframes topToBottom{
0% { visibility: hidden; }
10% { visibility: hidden; }
20% { visibility: hidden; }
30% { visibility: hidden; }
40% { visibility: hidden; }
50% { visibility: hidden; }
60% { visibility: hidden; }
70% { visibility: hidden; }
80% { visibility: hidden; }
90% { visibility: hidden; }
100% { visibility: visible; }
}
<h2>CSS Animations are
<div class="animated">
<span>cool.</span>
<span>neat.</span>
<span>awesome.</span>
<span>groovy.</span>
<span>magic.</span>
<span>more.</span>
<span>lorem.</span>
<span>pixel.</span>
<span>word.</span>
<span>ten.</span>
</div>
</h2>
I am trying to create an animation using CSS3 only which will display a list of items.
I've been able to create an animation that cycles through each item on the list, however, I cannot figure out a solution to having the animation end with the last item on the list displayed.
Essentially, I want the animation to end with the words "Johnney be good" displayed.
This has supposedly been asked and answered in: Stopping a CSS3 Animation on last frame
However, I cannot figure out if or how that solution can be applied to my problem. Thank for your help, it's very appreciated.
#sentence-wrapper{
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: serif;
padding: 10px;
}
.sentence{
margin: 0;
text-align: left;
text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
}
.sentence span{
color: #444;
font-size: 200%;
font-weight: normal;
}
.words{
display: inline;
text-indent: 10px;
}
.words-1 span{
position: absolute;
opacity: 0;
overflow: hidden;
color: #6b969d;
-webkit-animation: rotateWord 12s 1 0s;
-moz-animation: rotateWord 12s 1 0s;
-o-animation: rotateWord 12s 1 0s;
-ms-animation: rotateWord 12s 1 0s;
animation: rotateWord 12s 1 0s;
}
.words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-moz-animation-delay: 3s;
-o-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
color: #6b969d;
}
.words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #6b969d;
}
.words-1 span:nth-child(4) {
-webkit-animation-delay: 9s;
-moz-animation-delay: 9s;
-o-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
color: #6b969d;
}
#-webkit-keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -webkit-transform: translateY(-30px); }
5% { opacity: 1; -webkit-transform: translateY(0px);}
17% { opacity: 1; -webkit-transform: translateY(0px); }
20% { opacity: 0; -webkit-transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
<div id="sentence-wrapper">
<div class="sentence">
<span>Johnney </span>
<div class="words words-1">
<span><em>smart</em></span>
<span><em>clever</em></span>
<span><em>awesome</em></span>
<span>be good</span>
</div>
</div>
</div>
The "be good" <span> uses the same animation (rotateWord) as the other <span>s. Which ends with opacity: 0;. If you don't want "be good" to fade out after fading in, you should define a separate animation for it:
#keframes rotateWordFinal{
0% { opacity: 0; }
50% { opacity: 0; -webkit-transform: translateY(-30px); }
100% { opacity: 1; -webkit-transform: translateY(0px);}
}
.words-1 span:nth-child(4){
animation: rotateWordFinal 6s 1 9s;
}
Also: you're using all kind of prefixes for the animation properties, but not for the actual #keyframes. Better to keep that consistent.
You'll need to create a separate animation for the last span.
#sentence-wrapper{
font-family:serif;
margin:110px auto 0 auto;
padding:10px;
position:relative;
width:80%;
}
.sentence{
margin:0;
text-align:left;
text-shadow:1px 1px 1px rgba(255, 255, 255, 0.8);
}
.sentence span{
color:#444;
font-size:200%;
font-weight:normal;
}
.words{
display:inline;
text-indent:10px;
}
.words-1 span{
animation:rotateWord 12s 1 0s;
color:#6b969d;
opacity:0;
overflow:hidden;
position:absolute;
}
.words-1 span:nth-child(2){
animation-delay:3s;
}
.words-1 span:nth-child(3){
animation-delay:6s;
}
.words-1 span:last-child{
animation-delay: 9s;
animation-fill-mode: forwards;
animation-name:rotateLast;
}
#keyframes rotateWord{
0%,80%,100%{
opacity:0;
}
2% {
opacity:0;
transform:translateY(-30px);
}
5%,17%{
opacity:1;
transform: translateY(0px);
}
20%{
opacity:0;
transform:translateY(30px);
}
}
#keyframes rotateLast{
0%{
opacity:0;
}
2%{
opacity:0;
transform:translateY(-30px);
}
5%,100%{
opacity:1;
transform:translateY(0px);
}
}
<div id="sentence-wrapper">
<div class="sentence">
<span>Johnney </span>
<div class="words words-1">
<span><em>smart</em></span>
<span><em>clever</em></span>
<span><em>awesome</em></span>
<span>be good</span>
</div>
</div>
</div>
I've almost got it with animation-fill-mode and changing the 100% animation opacity to 1.
#sentence-wrapper {
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: serif;
padding: 10px;
}
.sentence {
margin: 0;
text-align: left;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.sentence span {
color: #444;
font-size: 200%;
font-weight: normal;
}
.words {
display: inline;
text-indent: 10px;
}
.words-1 span {
position: absolute;
opacity: 0;
overflow: hidden;
color: #6b969d;
-webkit-animation: rotateWord 12s 1 0s;
-moz-animation: rotateWord 12s 1 0s;
-o-animation: rotateWord 12s 1 0s;
-ms-animation: rotateWord 12s 1 0s;
animation: rotateWord 12s 1 0s linear backwards; /* all animations end at 0% value */
}
.words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-moz-animation-delay: 3s;
-o-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
color: #6b969d;
}
.words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #6b969d;
}
.words-1 span:nth-child(4) {
-webkit-animation-delay: 9s;
-moz-animation-delay: 9s;
-o-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
animation-fill-mode: forwards; /* This animation ends on 100% value */
color: #6b969d;
opacity: 0;
}
#-webkit-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 1; /* Changed from 0 to 1 */
}
}
<div id="sentence-wrapper">
<div class="sentence">
<span>Johnney </span>
<div class="words words-1">
<span><em>smart</em></span>
<span><em>clever</em></span>
<span><em>awesome</em></span>
<span>be good</span>
</div>
</div>
</div>
I have a background animation transition. it works on chrome, but not on chrome mobile. may i know which part is wrong? thanks.
.slideshow,
.slideshow:after {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 0;
}
.slideshow li{
list-style: none;
}
.slideshow li span {
overflow: hidden;
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: cover;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
z-index: 0;
animation: imageAnimation 32s linear infinite 0s;
-moz-animation: imageAnimation 32s linear infinite 0s;
-webkit-animation: imageAnimation 32s linear infinite 0s;
}
.slideshow li:nth-child(1) span {
background-image: url(../img/sbg.jpg);
}
.slideshow li:nth-child(2) span {
background-image: url(../img/sbg2.jpg);
animation-delay: 8s;
-moz-animation-delay: 8s;
-webkit-animation-delay: 8s;
}
.slideshow li:nth-child(3) span {
background-image: url(../img/sbg3.jpg);
animation-delay: 16s;
-moz-animation-delay: 16s;
-webkit-animation-delay: 16s;
}
.slideshow li:nth-child(4) span {
background-image: url(../img/sbg4.jpg);
animation-delay: 24s;
-moz-animation-delay: 24s;
-webkit-animation-delay: 24s;
}
#keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; -moz-animation-timing-function: ease-in; -webkit-animation-timing-function: ease-in;}
8% { opacity: 1; animation-timing-function: ease-out; -moz-animation-timing-function: ease-out; -webkit-animation-timing-function: ease-out; }
17% { opacity: 1; }
25% { opacity: 0; }
100% { opacity: 0 }
}
Have you tried inclduing webkit?
#-webkit-keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; -moz-animation-timing-function: ease-in; -webkit-animation-timing-function: ease-in;}
8% { opacity: 1; animation-timing-function: ease-out; -moz-animation-timing-function: ease-out; -webkit-animation-timing-function: ease-out; }
17% { opacity: 1; }
25% { opacity: 0; }
100% { opacity: 0 }
}
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.
I've been trying to create a CSS3 animations based slider and I am kind of puzzled by the logic behind the animation and keyframes.
here's what I've done: http://jsfiddle.net/fatgamer85/LzGR7
I created a container for the slider and another container inside the slider container which would hold divs or images. In this case I've decided to put in some images for starter.
<div class="slider">
<div class="slide"><span class="image"></span></div>
<div class="slide"><span class="image"></span></div>
<div class="slide"><span class="image"></span></div>
<div class="slide"><span class="image"></span></div>
<div class="slide"><span class="image"></span></div>
</div>
Then using CSS I've absolutely positioned these containers and images.
*, body, html{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.slider{
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
}
.slide{
position: absolute;
width: 100%;
height: 100%;
}
.slide .image{
float: left;
position: absolute;
}
I've then proceeded to add my animation rules to the .slide class
.slide
{
animation: myanimation 48s ease-in-out infinite;
-webkit-animation: myanimation 48s ease-in-out infinite;
-o-animation: myanimation 48s ease-in-out infinite;
-moz-animation: myanimation 48s ease-in-out infinite;
-ms-animation: myanimation 48s ease-in-out infinite;
}
and added animation rules to each of the class separately using the nth-child pseudo class.
I've observed that the images appear in wrong order, so I added z-index separately to these classes
.slide:nth-child(1){
animation-delay: 0s;
-webkit-animation-delay: 0s;
-moz-animation-delay: 0s;
-o-animation-delay: 0s;
-ms-animation-delay: 0s;
z-index:1;
}
.slide:nth-child(2){
animation-delay: 8s;
-webkit-animation-delay: 8s;
-moz-animation-delay: 8s;
-o-animation-delay: 8s;
-ms-animation-delay: 8s;
z-index:2;
}
..... and so on...
and began adding images to the span
.slide:nth-child(1) .image {
background-image: url('http://i.imgur.com/9yvKmZY.jpg');
background-repeat: no-repeat;
background-size: cover;
}
.slide:nth-child(2) .image {
background-image: url('http://i.imgur.com/j8mBdLD.jpg');
background-repeat: no-repeat;
background-size: cover;
}
..... and so on...
finally added keyframe rules
#-webkit-keyframes myanimation {
0%{
opacity: 1;
}
25% {
opacity: 0;
}
}
Everything looks fine and dandy.. But the problem starts when the Image starts animating.
I quite haven't grasped the concept of animation properly I guess..
Hence the slideshow goes bonkers animating with a mind of its own. Sometimes it doesn't even show the right order of the images or it skips the image completely.
Can anyone tell me what I am doing wrong or where I went wrong?
Here is a full screen example of the slider: http://fiddle.jshell.net/fatgamer85/LzGR7/23/show/light/
There is one thing about slides that makes you loose a lot of time if you don't know it.
If you delay your animations to the future, the first cicle is different from the others. Most of the elements have the properties that come from the static properties, and not from the animation.
To avoid this kind of prpblems, set you animations delay to the past. This way, the first animation cycle is equal to the others.
Also, it is nice to give yourself some help. In this case, I have set numbers to the left of the slide. This way, you can see really what is going on.
Besides, I have fixed a little bit you keyframes, at leats the webkit ones were wrong.
CSS
*, body, html{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.slider{
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
}
.slide{
position: absolute;
width: 100%;
height: 100%;
animation: myanimation 48s ease-in-out infinite;
-webkit-animation: myanimation 48s ease-in-out infinite;
-o-animation: myanimation 48s ease-in-out infinite;
-moz-animation: myanimation 48s ease-in-out infinite;
-ms-animation: myanimation 48s ease-in-out infinite;
font-size: 100px;
color: red;
}
.slide .image{
float: left;
position: absolute;
}
.slide:nth-child(1){
animation-delay: 0s;
-webkit-animation-delay: 0s;
-moz-animation-delay: 0s;
-o-animation-delay: 0s;
-ms-animation-delay: 0s;
z-index:5;
}
.slide:nth-child(2){
animation-delay: -40s;
-webkit-animation-delay: -40s;
-moz-animation-delay: -40s;
-o-animation-delay: -40s;
-ms-animation-delay: -40s;
z-index:4;
}
.slide:nth-child(3){
animation-delay: -30s;
-webkit-animation-delay: -30s;
-moz-animation-delay: -30s;
-o-animation-delay: -30s;
-ms-animation-delay: -30s;
z-index:3;
}
.slide:nth-child(4){
animation-delay: -20s;
-webkit-animation-delay: -20s;
-moz-animation-delay: -20s;
-o-animation-delay: -20s;
-ms-animation-delay: -20s;
z-index:2;
}
.slide:nth-child(5){
animation-delay: -10s;
-webkit-animation-delay: -10s;
-moz-animation-delay: -10s;
-o-animation-delay: -10s;
-ms-animation-delay: -10s;
z-index:1;
}
#keyframes myanimation {
0%{ opacity: 0; }
5%{opacity: 1; }
20%{opacity: 1; }
25% {opacity: 0;}
100% {opacity: 0;}
}
#-webkit-keyframes myanimation {
0%{ opacity: 0; }
5%{opacity: 1; }
20%{opacity: 1; }
25% {opacity: 0;}
100% {opacity: 0;}
}
#-o-keyframes myanimation {
0%{ opacity: 1; }
25% { opacity: 0.75; }
50%{ opacity: 0.5; }
75% { opacity: 0.25; }
100%{ opacity: 0; }
}
#-moz-keyframes myanimation {
0%{ opacity: 1; }
25% { opacity: 0.75; }
50%{ opacity: 0.5; }
75% { opacity: 0.25; }
100%{ opacity: 0; }
}
#-ms-keyframes myanimation {
0%{ opacity: 0; }
5%{opacity: 1; }
20%{opacity: 1; }
25% {opacity: 0;}
100% {opacity: 0;}
}
#-webkit-keyframes myanimation {
0%{ opacity: 0; }
5%{opacity: 1; }
20%{opacity: 1; }
25% {opacity: 0;}
100% {opacity: 0;}
}
.slide:nth-child(1) .image {
background-image: url('http://i.imgur.com/9yvKmZY.jpg');
background-repeat: no-repeat;
background-size: cover;
}
.slide:nth-child(2) .image {
background-image: url('http://i.imgur.com/j8mBdLD.jpg');
background-repeat: no-repeat;
background-size: cover;
}
.slide:nth-child(3) .image {
background-image: url('http://i.imgur.com/9VdDjQi.jpg');
background-repeat: no-repeat;
background-size: cover;
}
.slide:nth-child(4) .image {
background-image: url('http://i.imgur.com/dqCWOgW.jpg');
background-repeat: no-repeat;
background-size: cover;
}
.slide:nth-child(5) .image {
background-repeat: no-repeat;
background-image: url('http://i.imgur.com/0hUMMuT.jpg');
background-size: cover;
}
corrected demo
Happy coding !
In the above demo, the 5th image appears for a little bit of time at the start of the animation. This can be corrected adjusting the keyframes:
#keyframes myanimation {
0%{opacity: 1; }
15%{opacity: 1; }
20%{opacity: 0; }
95% {opacity: 0;}
100% {opacity: 1;}
}
If you draw this in a piece of paper, you will see why; but it's difficult to explain
new demo
About your fiddle with the bar, you make 2 errors. The problem is that you think that the bar are somehow "inside" the frame, and are bound to that "time". This is not true, you are working with a cycle of 40s, and the bar has to work with that animation time (not 9 seconds, and frames in fractions of this 9 seconds).
Your best option is to have only 1 bar, and make it cycling faster (at 10 seconds).
CSS
*, body, html{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.slider{
position: relative;
overflow: hidden;
width: 100%;
height: 400px;
}
.slide{
position: absolute;
width: 100%;
height: 100%;
animation: bg_anim 50s ease-in-out infinite;
-webkit-animation: bg_anim 50s ease-in-out infinite;
-o-animation: bg_anim 50s ease-in-out infinite;
-moz-animation: bg_anim 50s ease-in-out infinite;
-ms-animation: bg_anim 50s ease-in-out infinite;
}
.slide .image{
float: left;
position: absolute;
}
.slide:nth-child(1){
animation-delay: 0s;
-webkit-animation-delay: 0s;
-moz-animation-delay: 0s;
-o-animation-delay: 0s;
-ms-animation-delay: 0s;
z-index:5;
}
.slide:nth-child(2){
animation-delay: -40s;
-webkit-animation-delay: -40s;
-moz-animation-delay: -40s;
-o-animation-delay: -40s;
-ms-animation-delay: -40s;
z-index:4;
}
.slide:nth-child(3){
animation-delay: -30s;
-webkit-animation-delay: -30s;
-moz-animation-delay: -30s;
-o-animation-delay: -30s;
-ms-animation-delay: -30s;
z-index:3;
}
.slide:nth-child(4){
animation-delay: -20s;
-webkit-animation-delay: -20s;
-moz-animation-delay: -20s;
-o-animation-delay: -20s;
-ms-animation-delay: -20s;
z-index:2;
}
.slide:nth-child(5){
animation-delay: -10s;
-webkit-animation-delay: -10s;
-moz-animation-delay: -10s;
-o-animation-delay: -10s;
-ms-animation-delay: -10s;
z-index:1;
}
.text{
right: 0px;
color: #fff;
font-size: 28px;
float: right;
z-index:1;
}
.text:nth-child(1){
z-index:5;
}
.text:nth-child(2){
z-index:4;
}
.text:nth-child(3){
z-index:3;
}
.text:nth-child(4){
z-index:2;
}
.text:nth-child(5){
z-index:1;
}
.bar{
position: absolute;
width: 45%;
height: 400px;
right: -20px;
float: right;
z-index: 99;
animation: bar_anim 10s infinite ease-in-out;
-webkit-animation: bar_anim 10s infinite ease-in-out;
-o-animation: bar_anim 10s infinite ease-in-out;
-moz-animation: bar_anim 10s infinite ease-in-out;
-ms-animation: bar_anim 10s infinite ease-in-out;
animation-delay: -1.5s;
-webkit-animation-delay: -1.5s;
-moz-animation-delay: -1.5s;
-o-animation-delay: -1.5s;
-ms-animation-delay: -1.5s;
}
.slide:nth-child(1) > .bar{
animation-delay: 0s;
-webkit-animation-delay: 0s;
-moz-animation-delay: 0s;
-o-animation-delay: 0s;
-ms-animation-delay: 0s;
}
.slide:nth-child(2) > .bar{
animation-delay: -7.2s;
-webkit-animation-delay: -7.2s;
-moz-animation-delay: -7.2s;
-o-animation-delay: -7.2s;
-ms-animation-delay: -7.2s;
z-index:4;
}
.slide:nth-child(3) > .bar{
animation-delay: -5.4s;
-webkit-animation-delay: -5.4s;
-moz-animation-delay: -5.4s;
-o-animation-delay: -5.4s;
-ms-animation-delay: -5.4s;
z-index:3;
}
.slide:nth-child(4) > .bar{
animation-delay: -3.6s;
-webkit-animation-delay: -3.6s;
-moz-animation-delay: -3.6s;
-o-animation-delay: -3.6s;
-ms-animation-delay: -3.6s;
z-index:2;
}
.slide:nth-child(5) > .bar{
animation-delay: -1.8s;
-webkit-animation-delay: -1.8s;
-moz-animation-delay: -1.8s;
-o-animation-delay: -1.8s;
-ms-animation-delay: -1.8s;
z-index:1;
}
#keyframes bar_anim {
0% { right: -4000px; }
10% { right: 0px; }
15% { right: -20px;}
80% { right: -20px;}
95% { right: 0px; }
100% { right: -4000px; }
}
#-o-keyframes bar_anim {
0%{ right: -4000px; }
10%{ right: 0px; }
15%{ right: -20px; }
80% { right: -20px; }
95% { right: 0px; }
100% { right: -4000px; }
}
#-moz-keyframes bar_anim {
0%{ right: -4000px; }
10%{ right: 0px; }
15%{ right: -20px; }
80% { right: -20px; }
95% { right: 0px; }
100% { right: -4000px; }
}
#-ms-keyframes bar_anim {
0%{ right: -4000px; }
10%{ right: 0px; }
15%{ right: -20px; }
80% { right: -20px; }
95% { right: 0px; }
100% { right: -4000px; }
}
#-webkit-keyframes bar_anim {
0%{ right: -4000px; }
10%{ right: 0px; }
15%{ right: -20px; }
80% { right: -20px; }
95% { right: 0px; }
100% { right: -4000px; }
}
#keyframes bg_anim {
0%{ opacity: 1; }
15%{
opacity: 1;
}
20%{
opacity: 0;
}
95% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-webkit-keyframes bg_anim {
0%{
opacity: 1;
}
15%{
opacity: 1;
}
20%{
opacity: 0;
}
95% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes bg_anim {
0%{
opacity: 1;
}
15%{
opacity: 1;
}
20%{
opacity: 0;
}
95% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes bg_anim {
0%{
opacity: 1;
}
15%{
opacity: 1;
}
20%{
opacity: 0;
}
95% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-ms-keyframes bg_anim {
0%{
opacity: 1;
}
15%{
opacity: 1;
}
20%{
opacity: 0;
}
95% {
opacity: 0;
}
100% {
opacity: 1;
}
}
Alternatively, set 1 span for every slide if you need to, but then keep the animation time and delays.
Based on your code you have grasped the animation (keyframes) correctly. I think the issue is with the z-index, you should remove it. You missed a tiny single detail about the slide nth-child. You must set the nth-childs opacity to 0. I will leave the understanding to you :)
.slide:nth-child(3){
animation-delay: 16s;
-webkit-animation-delay: 16s;
-moz-animation-delay: 16s;
-o-animation-delay: 16s;
-ms-animation-delay: 16s;
opacity:0;
}