Skip to content

Instantly share code, notes, and snippets.

@schmidt1024
Last active August 29, 2015 14:14
Show Gist options
  • Save schmidt1024/7365095d79b280385059 to your computer and use it in GitHub Desktop.
Save schmidt1024/7365095d79b280385059 to your computer and use it in GitHub Desktop.
Simple jQuery Fader
<div id="fader">
<ul>
<li>FADE 1</li>
<li style="background: #aaa;">FADE 2</li>
<li>FADE 3</li>
<li style="background: #aaa;">FADE 4</li>
</ul>
</div>
jQuery(document).ready(function ($) {
$(function(){
$('#fader ul li:not(:first-child)').hide();
setInterval(function(){
$('#fader ul li:first-child').fadeOut()
.next('li').fadeIn()
.end().appendTo('#fader ul');
},
3000);
});
});
#fader {
position: relative;
overflow: hidden;
margin: 20px auto 0 auto;
}
#fader ul {
position: relative;
margin: 0;
padding: 0;
height: 300px;
list-style: none;
}
#fader ul li {
position: absolute;
display: block;
float: left;
margin: 0;
padding: 0;
width: 500px;
height: 300px;
background: #ccc;
text-align: center;
line-height: 300px;
}
#fader {
position: relative;
overflow: hidden;
margin: 20px auto 0 auto;
ul {
position: relative;
margin: 0;
padding: 0;
height: 300px;
list-style: none;
li {
position: absolute;
display: block;
float: left;
margin: 0;
padding: 0;
width: 500px;
height: 300px;
background: #ccc;
text-align: center;
line-height: 300px;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment