I have created a side navigation for a website, but I don't want it to overlay on top of my website. I want it to pushover the rest of the site. For example how they do it on this website. The code i have is below.
<div id="mainbox" onclick="openFunction()">☰ </div>
<div id="menu" class="sidemenu">
<a href="#">Home</a>
<a href="#">Shop</a>
<a href="#">About</a>
<a href="#">Contact</a>
<a href="#" class="closebtn" onclick="closeFunction()">×</a>
</div>
<script type="text/javascript">
function openFunction(){
document.getElementById("menu").style.width="400px";
document.getElementById("mainbox").style.marginLeft="400px";
}
function closeFunction(){
document.getElementById("menu").style.width="0px";
document.getElementById("mainbox").style.marginLeft="0px";
}
</script>
CSS:
#mainbox{
position: fixed;
font-size: 40px;
cursor: pointer;
transition: all .6s;
transform: translate(3750%, -1600%);
}
.sidemenu{
position: fixed;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
background-color: #FFEECA;
z-index: 1;
padding-top: 100px;
overflow-x: hidden;
transition: all .5s;
}
.sidemenu a{
padding: 8px 8px 8px 64px;
text-decoration: none;
font-size: 20px;
color: #222;
display: block;
}
.sidemenu a:hover{
color: white;
}
.sidemenu .closebtn{
position: absolute;
top: 0px;
right: 25px;
font-size: 36px;
margin-left: 32px;
}