<html>
<head>
<link rel="stylesheet" type="text/css" href="MainPage.css">
</head>
<body>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">Home</a>
<a href="#">Services</a>
</div>
<div id="main">
<img id="name" src="Name.png" class="center">
<span id="Menu" style="font-size:30px;cursor:pointer" onclick="openNav()">☰ Menu</span>
</div>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
</script>
</body>
</html>
CSS:
img.center {
display: block;
margin: 0 auto;
}
This is the code I am using to try and centre the image, but for some reason it is not working. Can you guys show me what I am doing wrong thank you.