css3 - CSS images slider animation doesn't work -
i'm new here , i'll try simplify questin. i'm sorry if break rules. i'm trying simple css silde image.
while i'm doing animation code, want picture fade left every link select. i'm doing video says not working.
@-webkit-keyframes 'slide'{ 0% {left:-500px;} 100%{left: 0} } ul.slides li:target { z-index: 100; -webkit-animation-name: slide; -webkit-animation-duration:1s; -webkit-animation-iteration-count:1; }
<!docotype html> <html> <head> <title>pure css slider</title> <link rel="stylesheet" href="file:///d:/css%20projects/css%20slider/style.css"/> </head> <body> <div id="container"> <h1>pure css slider</h1> <ul class="tumbs"> <li><a href="#slide-1"><img src="file:///d:/css%20projects/css%20slider/img/tumb1.jpg"> <span>this image 1</span></a></li> <li><a href="#slide-2"><img src="file:///d:/css%20projects/css%20slider/img/tumb2.jpg"><span>this image 2</span></a></li> <li><a href="#slide-3"><img src="file:///d:/css%20projects/css%20slider/img/tumb3.jpg"><span>this image 3</span></a></li> <li><a href="#slide-4"><img src="file:///d:/css%20projects/css%20slider/img/tumb4.jpg"><span>this image 4</span></a></li> <li><a href="#slide-5"><img src="file:///d:/css%20projects/css%20slider/img/tumb5.jpg"><span>this image 5</span></a></li> <li><a href="#slide-6"><img src="file:///d:/css%20projects/css%20slider/img/tumb6.jpg"><span>this image 6</span></a></li> <li><a href="#slide-7"><img src="file:///d:/css%20projects/css%20slider/img/tumb7.jpg"><span>this image 7</span></a></li> </ul> <ul class="slides"> <li class="first" id="slide-1"><img src="file:///d:/css%20projects/css%20slider/img/slide-1.jpg"> </li> <li id="slide-2"><img src="file:///d:/css%20projects/css%20slider/img/slide-2.jpg"> </li> <li id="slide-3"><img src="file:///d:/css%20projects/css%20slider/img/slide-3.jpg"> </li> <li id="slide-4"><img src="file:///d:/css%20projects/css%20slider/img/slide-4.jpg"> </li> <li id="slide-5"><img src="file:///d:/css%20projects/css%20slider/img/slide-5.jpg"> </li> <li id="slide-6"><img src="file:///d:/css%20projects/css%20slider/img/slide-6.jpg"> </li> <li id="slide-7"><img src="file:///d:/css%20projects/css%20slider/img/slide-7.jpg"> </li> </ul> </div> </body> </html>
your code doesn't work because:
left
applies elements positioned in way (relative
,absolute
,fixed
)position
. addli
/img
css. alternatively, usetransform: translatex(-500px);
jsfiddle - http://jsfiddle.net/njyu7qhk/1/
so, the relevant css should this:
@-webkit-keyframes slide { 0% { left: -500px; } 100% { left: 0; } } ul.slides li:target { z-index: 100; position: relative; -webkit-animation: slide 1s; }
i removed quotes in keyframes
name. seems work them, think it's 'standard' name without quotes. not sure on though.
good luck.
Comments
Post a Comment