繁体   English   中英

如何让我的侧边菜单推动我的网站?

[英]How do i make my side menu push my website over?

我为一个网站创建了一个侧面导航,但我不希望它覆盖在我的网站上。 我希望它能够推动网站的其余部分。 例如他们如何在这个网站上做到这一点 我的代码如下。


<div id="mainbox" onclick="openFunction()">&#9776; </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()">&times;</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;
}

拿铁...

 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { font-family: "Lato", sans-serif; } .sidenav { height: 100%; width: 0; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; 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 { color: #f1f1f1; } .sidenav .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; margin-left: 50px; } #main { transition: margin-left .5s; padding: 16px; } @media screen and (max-height: 450px) { .sidenav {padding-top: 15px;} .sidenav a {font-size: 18px;} } </style> </head> <body> <div id="mySidenav" class="sidenav"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a> <a href="#">hey</a> <a href="#">alles</a> <a href="#">oke</a> <a href="#">?</a> </div> <div id="main"> <h2>Sidenav Push Example</h2> <p>Click on the element below to open the side navigation menu, and push this content to the right.</p> <span style="font-size:30px;cursor:pointer" onclick="openNav()">&#9776; open</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>

给你,我希望它是你想要的...... lol https://codepen.io/schliflo/pen/Eawzzw

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM