Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Alessandro Elkan
Courses Plus Student 7,447 PointsAnimation - CSS- not quite working(crossfading)
I'm not sure how to get rid of the flickering and it doesnt seem to be working properly i want it to loop images 1 - 14
'''<div id="crossfade"> <img src="http://www.nousacademy.com/img/daytonight-1.jpg" alt="Image 1"> <img src="http://www.nousacademy.com/img/daytonight-2.jpg" alt="Image 2"> <img src="http://www.nousacademy.com/img/daytonight-3.jpg" alt="Image 3"> <img src="http://www.nousacademy.com/img/daytonight-4.jpg" alt="Image 4"> <img src="http://www.nousacademy.com/img/daytonight-5jpg" alt="Image 5"> <img src="http://www.nousacademy.com/img/daytonight-6.jpg" alt="Image 6"> <img src="http://www.nousacademy.com/img/daytonight-7.jpg" alt="Image 7"> <img src="http://www.nousacademy.com/img/daytonight-8.jpg" alt="Image 8"> <img src="http://www.nousacademy.com/img/daytonight-9.jpg" alt="Image 9"> <img src="http://www.nousacademy.com/img/daytonight-10.jpg" alt="Image 10"> <img src="http://www.nousacademy.com/img/daytonight-11.jpg" alt="Image 11"> <img src="http://www.nousacademy.com/img/daytonight-12.jpg" alt="Image 12"> <img src="http://www.nousacademy.com/img/daytonight-13.jpg" alt="Image 13"> <img src="http://www.nousacademy.com/img/daytonight-14.jpg" alt="Image 14"> </div>'''
'''#crossfade > img { width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; color: transparent; opacity: 0; z-index: 0; -webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; -webkit-animation: imageAnimation 1s linear infinite 0s; -moz-animation: imageAnimation 1s linear infinite 0s; -o-animation: imageAnimation 1s linear infinite 0s; -ms-animation: imageAnimation 1s linear infinite 0s; animation: imageAnimation 1s linear infinite 0s; }
crossfade > img:nth-child(2) {
-webkit-animation-delay: 2s;
-moz-animation-delay: 2s;
-o-animation-delay: 2s;
-ms-animation-delay: 2s;
animation-delay: 2s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(3) {
-webkit-animation-delay: 3s;
-moz-animation-delay: 3s;
-o-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(4) {
-webkit-animation-delay: 4s;
-moz-animation-delay: 4s;
-o-animation-delay: 4s;
-ms-animation-delay: 4s;
animation-delay: 4s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(5) {
-webkit-animation-delay: 5s;
-moz-animation-delay: 5s;
-o-animation-delay: 5s;
-ms-animation-delay: 5s;
animation-delay: 5s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(6) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(7) {
-webkit-animation-delay: 7s;
-moz-animation-delay: 7s;
-o-animation-delay: 7s;
-ms-animation-delay: 7s;
animation-delay: 7s;
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden; }
crossfade > img:nth-child(8) {
-webkit-animation-delay: 8s;
-moz-animation-delay: 8s;
-o-animation-delay: 8s;
-ms-animation-delay: 8s;
animation-delay: 8s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(9) {
-webkit-animation-delay: 9s;
-moz-animation-delay: 9s;
-o-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(10) {
-webkit-animation-delay: 10s;
-moz-animation-delay: 10s;
-o-animation-delay: 10s;
-ms-animation-delay: 10s;
animation-delay: 10s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(11) {
-webkit-animation-delay: 11s;
-moz-animation-delay: 11s;
-o-animation-delay: 11s;
-ms-animation-delay: 11s;
animation-delay: 11s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(12) {
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-o-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(13) {
-webkit-animation-delay: 13s;
-moz-animation-delay: 13s;
-o-animation-delay: 13s;
-ms-animation-delay: 13s;
animation-delay: 13s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
crossfade > img:nth-child(14) {
-webkit-animation-delay: 14s;
-moz-animation-delay: 14s;
-o-animation-delay: 14s;
-ms-animation-delay: 14s;
animation-delay: 14s;
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden; }
@-webkit-keyframes imageAnimation { 0% { opacity: 0; -webkit-animation-timing-function: ease-in; -webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden;} 7% { opacity: 1; -webkit-animation-timing-function: ease-out; -webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden;} 14% { opacity: 0; } 21% { opacity: 1; } 28% { opacity: 0; } 35% { opacity: 1; } 42% { opacity: 0; } 49% { opacity: 1; } 56% { opacity: 0; } 63% { opacity: 1; } 70% { opacity: 0; } 77% { opacity: 1; } 84% { opacity: 0; } 91% { opacity: 1; } 100% { opacity: 0; } } }
@-moz-keyframes imageAnimation { 0% { opacity: 0; -moz-animation-timing-function: ease-in; } 7% { opacity: 1; -moz-animation-timing-function: ease-out; } 14% { opacity: 0; -moz-animation-timing-function: ease-in;} 21% { opacity: 1; -moz-animation-timing-function: ease-out;} 28% { opacity: 0; } 35% { opacity: 1; } 42% { opacity: 0; } 49% { opacity: 1; } 56% { opacity: 0; } 63% { opacity: 1; } 70% { opacity: 0; } 77% { opacity: 1; } 84% { opacity: 0; } 91% { opacity: 1; } 100% { opacity: 0; } }
@-o-keyframes imageAnimation { 0% { opacity: 0; -o-animation-timing-function: ease-in; } 7% { opacity: 1; -o-animation-timing-function: ease-out; } 14% { opacity: 0; } 21% { opacity: 1; } 28% { opacity: 0; } 35% { opacity: 1; } 42% { opacity: 0; } 49% { opacity: 1; } 56% { opacity: 0; } 63% { opacity: 1; } 70% { opacity: 0; } 77% { opacity: 1; } 84% { opacity: 0; } 91% { opacity: 1; } 100% { opacity: 0; } } }
@-ms-keyframes imageAnimation { 0% { opacity: 0; -ms-animation-timing-function: ease-in; } 7% { opacity: 1; -ms-animation-timing-function: ease-out; } 14% { opacity: 0; } 21% { opacity: 1; } 28% { opacity: 0; } 35% { opacity: 1; } 42% { opacity: 0; } 49% { opacity: 1; } 56% { opacity: 0; } 63% { opacity: 1; } 70% { opacity: 0; } 77% { opacity: 1; } 84% { opacity: 0; } 91% { opacity: 1; } 100% { opacity: 0; } } }
@keyframes imageAnimation { 0% { opacity: 0; animation-timing-function: ease-in; } 7% { opacity: 1; animation-timing-function: ease-out; } 14% { opacity: 0; } 21% { opacity: 1; } 28% { opacity: 0; } 35% { opacity: 1; } 42% { opacity: 0; } 49% { opacity: 1; } 56% { opacity: 0; } 63% { opacity: 1; } 70% { opacity: 0; } 77% { opacity: 1; } 84% { opacity: 0; } 91% { opacity: 1; } 100% { opacity: 0; } } '''
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsI found this codepen: http://codepen.io/leemark/pen/vzCdo
Maybe you can adapt it to your needs.
Alessandro Elkan
Courses Plus Student 7,447 PointsNo not really, thanks anyway.