[英]Hamburger Menu on the same top nav bar as logo images
So after days of researching and meddling around, I simply can't seem to wrap my head around this concept. 因此,经过数天的研究和干预,我似乎根本无法将这个概念束之高阁。
What I'm trying to accomplish is to have a navigation bar at the top of the page with three components: 我要完成的工作是在页面顶部具有一个包含三个组件的导航栏:
Here is how I was attempting to show all of these 这就是我试图展示所有这些的方式
function openNav() { document.getElementById("myNav").style.height = "100%"; } function closeNav() { document.getElementById("myNav").style.height = "0%"; }
li{ text-decoration: none; } .overlay { height: 0%; width: 100%; position: fixed; z-index: 1; top: 0; left: 0; background-color: rgb(0,0,0); background-color: rgba(0,0,0, 0.9); overflow-y: hidden; transition: 0.5s; } .overlay-content { position: relative; top: 25%; width: 100%; text-align: center; margin-top: 0px; } .overlay a { padding: 8px; text-decoration: none; font-size: 36px; color: #818181; display: block; transition: 0.3s; } .overlay a:hover, .overlay a:focus { color: #f1f1f1; } .overlay .closebtn { position: absolute; top: 20px; right: 45px; font-size: 60px; } header{ width:100%; background:#1d1f20; height:60px; line-height:60px; } @media screen and (max-height: 450px) { .overlay {overflow-y: auto;} .overlay a {font-size: 20px} .overlay .closebtn { font-size: 80%; top: 15px; right: 35px; } }
<header> <div> <img src="" width="50px" height="30px"/> <img style="margin-left: 620px;" src="" width="50px" height="30px" /> <span style="font-size:30px;cursor:pointer; float: left;" onclick="openNav()">☰</span> <div id="myNav" class="overlay"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a> <div class="overlay-content"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Page1</a></li> <li><a href="#">Page2</a> <ul> <li><a href="#">Page3</a></li> <li><a href="#">Page4</a></li> <li><a href="#">Page5</a></li> </ul> </li> <li><a href="#">Page6</a> <ul> <li><a href="#">Page7</a></li> </ul> </li> <li><a href="#">Page8</a> <ul> <li><a href="#">Page9</a></li> <li><a href="#">Page10</a></li> </ul> </li> <li><a href="#">Page11</a></li> </ul> </div> </div> </div> </header>
Any Help or guidence would be very much appreciated. 任何帮助或指导将不胜感激。 I'm still learning! 我还在学习! :) Thank you! :) 谢谢!
your hamburger icon is floated to the left. 您的汉堡图标浮在左侧。 just change it to float:right; 只需将其更改为float:right;
function openNav() { document.getElementById("myNav").style.height = "100%"; } function closeNav() { document.getElementById("myNav").style.height = "0%"; }
span{ float: right !important; color: white; } li{ text-decoration: none; } .overlay { height: 0%; width: 100%; position: fixed; z-index: 1; top: 0; left: 0; background-color: rgb(0,0,0); background-color: rgba(0,0,0, 0.9); overflow-y: hidden; transition: 0.5s; } .overlay-content { position: relative; top: 25%; width: 100%; text-align: center; margin-top: 0px; } .overlay a { padding: 8px; text-decoration: none; font-size: 36px; color: #818181; display: block; transition: 0.3s; } .overlay a:hover, .overlay a:focus { color: #f1f1f1; } .overlay .closebtn { position: absolute; top: 20px; right: 45px; font-size: 60px; } header{ width:100%; background:#1d1f20; height:60px; line-height:60px; } @media screen and (max-height: 450px) { .overlay {overflow-y: auto;} .overlay a {font-size: 20px} .overlay .closebtn { font-size: 80%; top: 15px; right: 35px; } }
<header> <div> <img src="" width="50px" height="30px"/> <img style="margin-left: 620px;" src="" width="50px" height="30px" /> <span style="font-size:30px;cursor:pointer; float: left;" onclick="openNav()">☰</span> <div id="myNav" class="overlay"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a> <div class="overlay-content"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Page1</a></li> <li><a href="#">Page2</a> <ul> <li><a href="#">Page3</a></li> <li><a href="#">Page4</a></li> <li><a href="#">Page5</a></li> </ul> </li> <li><a href="#">Page6</a> <ul> <li><a href="#">Page7</a></li> </ul> </li> <li><a href="#">Page8</a> <ul> <li><a href="#">Page9</a></li> <li><a href="#">Page10</a></li> </ul> </li> <li><a href="#">Page11</a></li> </ul> </div> </div> </div> </header>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.