sideBar-flat-component
by murgiaMarco
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
</head>
<body>
<!-- Sidebar -->
<div class="sideBar" style="display:block" id="Sidebar">
<div class="clear sideBarInner" id="InnerSidebar">
<div class="content">Link 1</div>
</div>
</div>
<div onclick="toggle()" class="sidebarPop" id="SidebarButton" ><div class="arrow" id="arrow"></div></div>
<!-- Sidebar -->
<script>
function onLoadSet() {
var elmnt = (document.getElementById("InnerSidebar").offsetHeight / 2) - (document.getElementById("SidebarButton").offsetHeight / 2);
document.getElementById("SidebarButton").style.setProperty("top", elmnt + "px");
document.getElementById("SidebarButton").style.setProperty("right", "0px");
document.getElementById("Sidebar").style.display = "none";
}
window.onload = onLoadSet;
function toggle() {
if (document.getElementById("SidebarButton").style.right != "0px") {
document.getElementById("Sidebar").style.display = "none";
document.getElementById("SidebarButton").style.setProperty("right", "0px");
document.getElementById("arrow").style.transform = "rotate(-45deg)";
document.getElementById("arrow").style.setProperty("left", "5px");
} else {
document.getElementById("Sidebar").style.display = "block";
document.getElementById("SidebarButton").style.setProperty("right", (document.getElementById("InnerSidebar").offsetWidth-1) + "px");
document.getElementById("arrow").style.transform = "rotate(-225deg)";
document.getElementById("arrow").style.setProperty("left", "-5px");
}
}
</script>
</body>
</html>
CSS
.sideBar {
display: block;
position: fixed;
top: 0px;
right: 0px;
width: auto;
height: 100%;
pointer-events: none;
}
.sideBarInner {
display: block;
overflow-y: auto;
position: relative;
max-height: 100%;
top: 0px;
left: 0px;
pointer-events: all;
/* box-shadow:#000000 0px 2px 6px, #000000 0px -2px 6px 0px, #000000 -2px 0px 6px 0px; */
border: 4px #009688 solid;
background-color: #009688;
/* border-top-left-radius:10px; */
/* border-bottom-left-radius:10px; */
}
.content {
margin-right: 2px;
display: block;
position: relative;
border: 4px #009688 solid;
border-right: 0px;
border-radius: 3px;
width:300px;
height: 80px;
background-color: #ffffff;
pointer-events: all;
z-index: 99;
}
.sidebarPop {
background-color: #009688;
background-repeat: no-repeat;
border: none;
cursor: pointer;
outline: none;
display: inline-block;
position: fixed;
width: 20px;
height: 30px;
pointer-events: all;
/* border-top-left-radius:2px; */
/* border-bottom-left-radius:2px; */
/* box-shadow:#000000 -2px 2px 2px, #000000 -2px -2px 2px; */
z-index: 0;
}
.clear {
clear: both;
}
.arrow {
position: relative;
left: 5px;
top:5px;
width: 12px;
height: 12px;
border: 3.5px solid;
border-color: white transparent transparent white;
transform: rotate(-45deg);
}
.sideBarInner::-webkit-scrollbar {
width: 8px;
}
.sideBarInner::-webkit-scrollbar-track {
border-left: 2px solid transparent;
border-right: 2px solid transparent;
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}
.sideBarInner::-webkit-scrollbar-thumb {
border-radius: 5px;
background: black;
}