CSS:
html, body {
height: 100%;
width: 100%;
overflow: hidden;
}
#sidebar {
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto 20px 5px;
grid-template-areas: "1"
"box"
"3";
height: 100%;
width: 275px;
background: black;
}
#sidebar-box {
grid-area: box;
height: 20px;
width: auto;
margin: 0 12.5px 0 12.5px;
background-color: white;
}
#sidebar-open-button {
margin-top: 40%;
height: 50px;
width: 50px;
background-color: blue;
}
#sidebar-close-button {
height: 15px;
width: 15px;
background-color: red;
margin-left: 5px;
}
HTML
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="sidebar">
<div id="sidebar-box">
<button id="sidebar-close-button"></button>
</div>
</div>
</body>
</html>
What Im looking for is whenever you press the "sidebar-close-button" button the "sidebar" and its contents slowly (over 0.5s) move off screen to the left and while that is moving off screen the "sidebar-open-button" does the exact same thing but to the right (comes onto screen, sliding in from the left). Also when "sidebar-open-button" is sliding onto screen I want it to be on top of "sidebar" and its contents.
The end product of pressing "sidebar-close-button" should look like just having your html like this:
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<button id="sidebar-open-button"></button>
</body>
</html>
Any help is appreciated, even links to some documentation because I currently have no idea how to do this.