Created
March 18, 2014 10:17
-
-
Save iporsut/9617262 to your computer and use it in GitHub Desktop.
jQuery Slide Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Slide</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.js"></script> | |
<style type="text/css"> | |
#slide-wrapper { | |
width: 200px; | |
height: 200px; | |
position: relative; | |
margin: 0; | |
padding: 0; | |
border: 0; | |
overflow: hidden; | |
} | |
#slide-frame { | |
height: 200px; | |
width: 600px; | |
margin: 0; | |
padding: 0; | |
position: absolute; | |
left: 0; | |
} | |
.staff { | |
width: 200px; | |
height: 200px; | |
margin: 0; | |
padding: 0; | |
float: left; | |
} | |
.red { | |
background-color:red; | |
} | |
.blue { | |
background-color:blue; | |
} | |
.clear { | |
clear: both; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="slide-wrapper"> | |
<div id="slide-frame"> | |
<div class="staff red"> | |
</div> | |
<div class="staff blue"> | |
</div> | |
<div class="staff red"> | |
</div> | |
<div class="clear"></div> | |
</div> | |
</div> | |
<button id="left"><<</button> | |
<button id="right"> >></button> | |
<script type="text/javascript"> | |
$("#left").bind("click", function() { | |
$("#slide-frame").animate({ | |
left: "-=200", | |
}, 500, function() { | |
}); | |
}) | |
$("#right").bind("click", function() { | |
$("#slide-frame").animate({ | |
left: "+=200", | |
}, 500, function() { | |
}); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment