简体   繁体   English

汉堡菜单与徽标图像位于同一顶部导航栏上

[英]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: 我要完成的工作是在页面顶部具有一个包含三个组件的导航栏:

  • An Image (Logo1) on the left hand side of the top navigation bar. 顶部导航栏左侧的图像(Logo1)。
  • An Image (Logo2) in the center of the navigation bar. 导航栏中央的图像(Logo2)。
  • ..and finally, a hamburger menu on the very right, that slides down the whole page with opacity, and with link items to navigate through out the site. ..最后是最右边的一个汉堡菜单,它在整个页面上不透明,并带有链接项,可在整个站点中浏览。

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()">&#9776;</span> <div id="myNav" class="overlay"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</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()">&#9776;</span> <div id="myNav" class="overlay"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</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.

相关问题 当移动或桌面导航栏时显示汉堡菜单 - Display hamburger menu when mobile else desktop nav bar 在侧面菜单和导航栏上加载相同的链接 - Load same links on side menu and nav bar 使用bootstrap在移动平台其他桌面导航栏时显示汉堡菜单 - Display hamburger menu when mobile platform else desktop nav bar using bootstrap 如何创建带有徽标和某些选项和搜索栏的下拉列表的导航栏链接菜单? - How do I create a nav bar link menu with a logo and a dropdown list for some of the choices and a search bar? 试图居中导航栏和汉堡图标 - Trying to center my nav bar and hamburger icon 响应式导航栏中的汉堡包图标无法正常运行 - Hamburger icon in responsive nav bar not functioning properly 如何在引导程序中为我的顶部导航栏添加徽标容器和水平分隔符? - How to add a container for a logo and a horizontal divider for my top nav bar in bootstrap? 如何阻止我的汉堡包图标停留在顶部栏上,使其出现在侧面菜单中? - How do I stop my hamburger icon from staying with top bar so it appears with the side menu? 单击汉堡菜单后,我的导航菜单在桌面显示器上消失了? - My nav menu disappears on desktop displays after clicking the hamburger menu? 汉堡菜单与主导航菜单不匹配 - hamburger menu won't align with main nav menu
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM