For more information on these, check this updated post: cross browser implementation.
Image 1Image 2Image 3Image 4
Firstly, the mark up:
<div id="slide1_container"> <div id="slide1_images"> <img src="/images/Cirques.jpg" /> <img src="/images/Clown%20Fish.jpg" /> <img src="/images/Stones.jpg" /> <img src="/images/Summit.jpg" /> </div> </div> <p id="slide1_controls"> <span id="slide1-1">Image 1</span> <span id="slide1-2">Image 2</span> <span id="slide1-3">Image 3</span> <span id="slide1-4">Image 4</span> </p>
The CSS:
#slide1_controls span {
padding-right:2em;
cursor:pointer;
}
#slide1_container {
width:450px;
height:281px;
overflow:hidden;
position:relative;
}
#slide1_images {
position:absolute;
left:0px;
width:1800px;
-webkit-transition:all 1.0s ease-in-out;
-moz-transition:all 1.0s ease-in-out;
-o-transition:all 1.0s ease-in-out;
-ms-transition:all 1.0s ease-in-out;
transition:all 1.0s ease-in-out;
}
#slide1_images img {
padding:0;
margin:0;
float:left;
}
Again, I'm using javascript to bind events to the clickable controls. This time I'm adding the number of pixels to slide into the js, though I could have defined classes for this.
$(document).ready(function() {
$("#slide1-1").click(function() {
$("#slide1_images").css("left","0");
});
$("#slide1-2").click(function() {
$("#slide1_images").css("left","-450px");
});
$("#slide1-3").click(function() {
$("#slide1_images").css("left","-900px");
});
$("#slide1-4").click(function() {
$("#slide1_images").css("left","-1350px");
});
});
This code could be abstracted and improved, but we are looking to keep it simple here.
Please add any questions/corrections/extra info below. Please be courteous to other users.
blog comments powered by Disqus