Instantly share code, notes, and snippets.
Last active
August 31, 2017 13:30
-
Save rambhairao/64a6608346388daff1c8042aef50c06b to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/mamelisido
This file contains 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
.button { | |
background-color: #4CAF50; /* Green */ | |
border: none; | |
color: white; | |
padding: 15px 32px; | |
text-align: center; | |
text-decoration: none; | |
display: inline-block; | |
font-size: 16px; | |
cursor: pointer; | |
} | |
.sidebar{ | |
background-color: red; | |
position: fixed; | |
width: 300px; | |
top: 100px; | |
right: 0px; | |
transition: transform 1s ease-in-out; | |
} | |
.sidebar li { | |
padding-top: 15px; | |
} | |
.sidebar.is-hidden{ | |
transform: translateX(300px); | |
} |
This file contains 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> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.button { | |
background-color: #4CAF50; /* Green */ | |
border: none; | |
color: white; | |
padding: 15px 32px; | |
text-align: center; | |
text-decoration: none; | |
display: inline-block; | |
font-size: 16px; | |
cursor: pointer; | |
} | |
.sidebar{ | |
background-color: red; | |
position: fixed; | |
width: 300px; | |
top: 100px; | |
right: 0px; | |
transition: transform 1s ease-in-out; | |
} | |
.sidebar li { | |
padding-top: 15px; | |
} | |
.sidebar.is-hidden{ | |
transform: translateX(300px); | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
<button class="button"> click me </button> | |
</div> | |
<div class="sidebar is-hidden"> | |
<ul> | |
<li> <a href="#" > sidebar 1 </a> </li> | |
<li> <a href="#" > sidebar 2 </a> </li> | |
<li> <a href="#" > sidebar 3 </a> </li> | |
<li> <a href="#" > sidebar 4 </a> </li> | |
<li> <a href="#" > sidebar 5 </a> </li> | |
</ul> | |
</div> | |
<script id="jsbin-javascript"> | |
var press = document.querySelector('.button'); | |
var side = document.querySelector('.sidebar'); | |
press.addEventListener('click', function(){ | |
if(side.classList.contains("is-hidden")){ | |
side.classList.remove("is-hidden"); | |
} else { | |
side.classList.add('is-hidden'); | |
} | |
}) | |
</script> | |
<script id="jsbin-source-css" type="text/css">.button { | |
background-color: #4CAF50; /* Green */ | |
border: none; | |
color: white; | |
padding: 15px 32px; | |
text-align: center; | |
text-decoration: none; | |
display: inline-block; | |
font-size: 16px; | |
cursor: pointer; | |
} | |
.sidebar{ | |
background-color: red; | |
position: fixed; | |
width: 300px; | |
top: 100px; | |
right: 0px; | |
transition: transform 1s ease-in-out; | |
} | |
.sidebar li { | |
padding-top: 15px; | |
} | |
.sidebar.is-hidden{ | |
transform: translateX(300px); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var press = document.querySelector('.button'); | |
var side = document.querySelector('.sidebar'); | |
press.addEventListener('click', function(){ | |
if(side.classList.contains("is-hidden")){ | |
side.classList.remove("is-hidden"); | |
} else { | |
side.classList.add('is-hidden'); | |
} | |
})</script></body> | |
</html> |
This file contains 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
var press = document.querySelector('.button'); | |
var side = document.querySelector('.sidebar'); | |
press.addEventListener('click', function(){ | |
if(side.classList.contains("is-hidden")){ | |
side.classList.remove("is-hidden"); | |
} else { | |
side.classList.add('is-hidden'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment