I am currently working on creating a CSS and JavaScript side navigation. Below is the code that I have implemented so far:
var nav = document.getElementById('nav');
function show(){
nav.style.display = "block";
}
.side-nav{
background-color:black;
height:100%;
width:250px;
position: absolute;
display:none;
}
#myLink{
color:gray;
text-decoration: none;
display:block;
margin-left:15px;
margin-bottom:10px;
font-size:25px;
transition: .5s;
font-family: 'Marck Script', cursive;
margin-top:10px;
}
#myLink:hover{
color:white;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css2?family=Marck+Script&display=swap" rel="stylesheet">
</head>
<body>
<div class = "side-nav" id = "nav">
<div id = "myLinks">
<a href="#" id="myLink">Home</a>
<a href="#" id="myLink">Contact</a>
<a href="#" id="myLink">Blog</a>
<a href="#" id="myLink">Products</a>
</div>
</div>
<a href="#" onclick="show();">Show nav</a>
<script src="script.js"></script>
</body>
</html>
I am seeking advice on how to create a smooth sliding effect from left to right with the side navigation. Can this be achieved using only CSS or do I still need to incorporate JavaScript? Any help would be greatly appreciated! Thank you!