Skip to content

Instantly share code, notes, and snippets.

@Mouad-BGD
Created June 7, 2012 12:19
Show Gist options
  • Select an option

  • Save Mouad-BGD/2888517 to your computer and use it in GitHub Desktop.

Select an option

Save Mouad-BGD/2888517 to your computer and use it in GitHub Desktop.
slides
html
----
<div class="slideshow">
<h1>Text</h1>
<input type="button" value="Hello" />
</div>
css
---
slideshow
{
position: relative;
width: 350px;
height: 150px;
}
.slideshow img
{
position: absolute;
width: 350px;
height: 150px;
z-index:-1;
}
js
--
var images=new Array('http://placehold.it/250x150','http://placehold.it/250x150/123456','http://placehold.it/250x150/dbca98');
var nextimage=0;
doSlideshow();
function doSlideshow()
{
if($('.slideshowimage').length!=0)
{
$('.slideshowimage').fadeOut(500,function(){slideshowFadeIn();$(this).remove()});
}
else
{
slideshowFadeIn();
}
}
function slideshowFadeIn()
{
$('.slideshow').prepend($('<img class="slideshowimage" src="'+images[nextimage++]+'" style="display:none">').fadeIn(500,function(){setTimeout(doSlideshow,1000);}));
if(nextimage>=images.length)
nextimage=0;
}
demo
-----
http://jsfiddle.net/R4ZHX/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment