-
-
Save LandRover/3683816 to your computer and use it in GitHub Desktop.
Slider
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>Transitions Demo</title> | |
<style> | |
body { overflow:hidden; } | |
#container { | |
width:200%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} | |
.page { | |
width:50%; | |
height:300px; | |
float:left; | |
} | |
.page1 { | |
background: blue; | |
} | |
.page2 { | |
background: orange; | |
} | |
.next { | |
-webkit-transition: all 2s; | |
left: -100% !important; | |
} | |
.prev { | |
-webkit-transition: all 2s; | |
left: 0 !important; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<div class="page page1"> | |
<button id="btn-next" onclick="next()">next</button> | |
</div> | |
<div class="page page2"> | |
<button id="btn-prev" onclick="prev()">prev</button> | |
</div> | |
</div> | |
<script> | |
function next() { | |
document.querySelector('#container').setAttribute('class', 'next'); | |
} | |
function prev() { | |
document.querySelector('#container').setAttribute('class', 'prev'); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/a2cLG/