Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- /* the slide container with a fixed size */
- .slides {
- box-shadow: 0px 0px 6px black;
- margin: 0 auto;
- width: 500px;
- height: 300px;
- position: relative;
- }
- /* the images are positioned absolutely to stack. opacity transitions are animated. */
- .slides img {
- display: block;
- position: absolute;
- transition: opacity 1s;
- opacity: 0;
- width: 100%;
- }
- /* the first image is the current slide. it's faded in. */
- .slides img:first-child {
- z-index: 2; /* frontmost */
- opacity: 1;
- }
- /* the last image is the previous slide. it's behind the current slide and it's faded over. */
- .slides img:last-child {
- z-index: 1; /* behind current slide */
- opacity: 1;
- }
- </style>
- <div class="slides">
- <img src="http://lorempixel.com/500/300/?r=1">
- <img src="http://lorempixel.com/500/300/?r=2">
- <img src="http://lorempixel.com/500/300/?r=3">
- <img src="http://lorempixel.com/500/300/?r=4">
- <img src="http://lorempixel.com/500/300/?r=5">
- </div>
- <script>
- function nextSlide() {
- var q = function(sel) { return document.querySelector(sel); }
- q(".slides").appendChild(q(".slides img:first-child"));
- }
- setInterval(nextSlide, 3000)
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement