简体   繁体   English

导航栏折叠菜单与实际导航栏的宽度不同。 我该如何解决? 导航栏也不会出现在较小的窗口中

[英]Navbar collapse menu is not the same width as the actual navbar. How do I fix that? Navbar also doesn't appear in smaller windows

I am trying to make a sticky navbar, that will be collapsable in smaller windows(smartphones).我正在尝试制作一个粘性导航栏,它可以在较小的窗口(智能手机)中折叠。 The first issue is that it looks like this (pic included) and doesn't have the same width as the actual navbar.第一个问题是它看起来像这样(包括图片)并且与实际导航栏的宽度不同。 The second issue is that navbar doesn't fade in, in smaller windows.第二个问题是导航栏不会在较小的窗口中淡入。 I am fairly new to this, so any suggestions will be welcome.我对此相当陌生,因此欢迎提出任何建议。

EDIT: I added a codepen编辑:我添加了一个代码笔

Codepen代码笔

Picture图片

enter image description here在此处输入图片说明

This is what I have included in project这是我在项目中包含的内容

enter code here

If I inspect your page, I can see that your panel is inside #navbar and this element has 1rem padding on the sides.如果我检查您的页面,我可以看到您的面板位于#navbar并且此元素的两侧有1rem填充。 So when you put 100% width, it is the width of the parent ie inside the padding.因此,当您放置100%宽度时,它是父级的宽度,即内边距。 What you need to do is to not have the padding on the big container itself.您需要做的是不要在大容器本身上填充填充物。 Instead you put this padding separately on the top bar with the button and on the panel.相反,您将此填充单独放置在带有按钮的顶部栏和面板上。

You may have to create another container to fix your issue.您可能需要创建另一个容器来解决您的问题。 Although you are using Bootstrap (which I am not familiar with).尽管您使用的是 Bootstrap(我不熟悉)。 It might not be as easy to remove padding but all I can say is that this is the reason why your nav panel is not full width on mobile.删除填充可能并不那么容易,但我只能说这就是为什么您的导航面板在移动设备上不是全宽的原因。

I know as a fact that making this sort of navigation bar which works nicely on desktop and mobile with a panel is not easy to achieve.我知道制作这种在桌面和移动设备上都能很好地使用面板的导航栏并不容易实现。 Good luck.祝你好运。

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

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