以下是我尝试做的事情This is the main image的图片,然后点击菜单everything moves right
我得到了正确的推送菜单,切换开关菜单加上主要的div已经找到了。我需要在div中居中点击3行,我需要div来占用页面的长度,我需要将徽标放在div的中心。
这是我当前的代码
<html>
<head>
<style>
body {
font-family: "Lato", sans-serif;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #212121;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a:hover, .offcanvas a:focus{
color: #f1f1f1;
}
.sidenav p {
position: absolute;
bottom: 100px;
color: #CACFD2;
font-size: 12px;
left:10%;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
.sidenav a.mail {
color: #CACFD2;
font-size: 12px;
left:10%;
padding: 0;
text-decoration: none;
}
#logozone {
background-color: #212121;
transition: margin-left .5s;
float: left;
width: 10%;
height: 100%;
padding: 2px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 2px;}
.sidenav a {font-size: 18px;}
}
</style>
</head>
<body>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">Home</a>
<a href="#">Current Projects</a>
<p>client info</p>
</div>
<div id="logozone">
<span style="text-align:center; font-size:30px;color:#CACFD2;cursor:pointer" onclick="openNav()">☰
<div><img src="logo.jpg"></div>
</div>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("logozone").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("logozone").style.marginLeft= "0";
}
</script>
</div>
<div>This is a test</div>
</body>
</html>
提前谢谢......这是我之前没有使用的编码
答案 0 :(得分:0)
尝试将#Logomenu和#logo的位置从绝对更改为相对,并且不需要在sidenav类中添加z-index,让它在同一个画布上。