Skip to content

Instantly share code, notes, and snippets.

@LandRover
Forked from ynonp/slider.html
Created September 9, 2012 11:04
Show Gist options
  • Save LandRover/3683816 to your computer and use it in GitHub Desktop.
Save LandRover/3683816 to your computer and use it in GitHub Desktop.
Slider
<!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>
@LandRover
Copy link
Author

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