Skip to content

Instantly share code, notes, and snippets.

@arielsalminen
Created May 15, 2011 12:55
Show Gist options
  • Save arielsalminen/973126 to your computer and use it in GitHub Desktop.
Save arielsalminen/973126 to your computer and use it in GitHub Desktop.
Responsive jQuery slideshow
#slideshow {
width: 100%;
position: relative;
}
img {
top: 0;
left: 0;
width: 100%;
max-width: 600px;
height: auto;
position: absolute;
}
<div id="slideshow">
<img src="1.jpg" />
<img src="2.jpg" />
<img src="3.jpg" />
</div>
$(function () {
// Simplest jQuery slideshow by Jonathan Snook
$('#slideshow img:gt(0)').hide();
setInterval(function () {
$('#slideshow :first-child').fadeOut(1000)
.next('img').fadeIn(1000).end().appendTo('#slideshow');
}, 4000);
});
@arielsalminen
Copy link
Author

This gist makes it possible to have fluid jQuery slideshow which scales responsively. I am using Jonathan Snook's Simple jQuery Slideshow in this example, but you can really use any JavaScript slideshow solution with this HTML/CSS combo.

@arielsalminen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment