Skip to content

Instantly share code, notes, and snippets.

Created July 2, 2013 22:41
Show Gist options
  • Save anonymous/5913899 to your computer and use it in GitHub Desktop.
Save anonymous/5913899 to your computer and use it in GitHub Desktop.
A CodePen by A Non Ymous.
<ul class="simple-gallery">
<li class="show">
<img src="http://minimalmonkey.com/examples/simple-gallery/images/image-1.jpg" />
</li>
<li>
<img src="http://minimalmonkey.com/examples/simple-gallery/images/image-2.jpg" />
</li>
<li>
<img src="http://minimalmonkey.com/examples/simple-gallery/images/image-3.jpg" />
</li>
</ul>
(function() {
var items = $('.simple-gallery li');
var total = items.length;
var current = 0;
setInterval(function() {
$(items[current]).removeClass('show');
++current;
if(current >= total) current = 0;
$(items[current]).addClass('show');
}, 3000);
})();
body {
margin: 0;
padding: 0;
}
ul {
list-style: none;
}
ul, li {
margin: 0;
padding: 0;
}
li {
-webkit-transition: opacity 1s, margin-left 0s linear 0.4s;
-moz-transition: opacity 1s, margin-left 0s linear 0.4s;
-o-transition: opacity 1s, margin-left 0s linear 0.4s;
transition: opacity 1s, margin-left 0s linear 0.4s;
height: 0;
left: 0;
margin-left: -99999px;
opacity: 0;
overflow: hidden;
padding-bottom: 50%;
position: absolute;
top: 0;
}
.show {
-webkit-transition: opacity 1s, margin-left 0s;
-moz-transition: opacity 1s, margin-left 0s;
-o-transition: opacity 1s, margin-left 0s;
transition: opacity 1s, margin-left 0s;
margin-left: 0;
opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment