简体   繁体   English

侧面导航栏未显示在手机中?

[英]Side Nav Bar not showing in mobile?

So I'm still new to the whole css and div thing, pardon my bad coding. 所以我对整个CSS和div还是陌生的,请原谅我的错误编码。 :/ Anyways, I have finished a site but oddly the side navbar does not appear on mobile browsers such as Chrome and the default android one. :/总之,我已经完成了一个站点,但奇怪的是,侧面导航栏未出现在移动浏览器(例如Chrome和默认的android)上。 Any ideas as to why? 有什么想法吗? All help is appreciated. 感谢所有帮助。

http://escobarboxing.com/ http://escobarboxing.com/

Also, I've tested it on my Desktop via Chrome, FF, and Opera and it appears to be working fine but another user using Chrome said he did not see it? 另外,我已经通过Chrome,FF和Opera在我的桌面上对其进行了测试,并且看起来工作正常,但是另一个使用Chrome的用户说他看不到它吗?

Yep, that's because of this: #menu{position: absolute;} 是的,这是因为:#menu {position:absolute;}

Because the position is absolute, and the main content is centered, when you get to a small screen size, the menu goes behind the content. 因为位置是绝对的,并且主要内容居中,所以当屏幕尺寸较小时,菜单将位于内容后面。 You can experiment with this just by resizing your screen really narrow. 您可以通过将屏幕调整得非常窄来进行试验。

For a quick fix, remove the position: absolute, which will fix your problem, but here's what I recommend: 为了快速解决,请删除位置:absolute,它将解决您的问题,但我建议您这样做:

Remove position absolute and relative from #menu and #container. 从#menu和#container中删除绝对位置和相对位置。 Remove Margin right and left: auto from #container, then float #container left (float:left;). 从#container删除左右边距:自动,然后向左浮动#container(float:left;)。 Finally, apply the auto left and right margins to #site (you'll need to specify a width first, looks like 920px should work). 最后,将自动左右边距应用于#site(您需要先指定宽度,看起来920px应该可以)。 The #menu will stay next to the #container, and both will be centered with regards to the page. #菜单将保留在#容器旁边,并且两者都将以页面为中心。

For good measure, I'd add a 100% height and width div (#wrapper) above site. 为了取得良好的效果,我会在网站上方添加100%的高度和宽度div(#wrapper)。

Also, side note, if you put "position: absolute;" 另外,请注意,如果您输入“ position:absolute;” on anything, it's removed from the 'flow' of elements, so margins won't affect it. 在任何东西上,它都从元素的“流”中删除,因此边距不会影响它。 Here's a great article that helped me figure out position: http://www.barelyfitz.com/screencast/html-training/css/positioning/ 这是一篇很棒的文章,可以帮助我确定位置: http : //www.barelyfitz.com/screencast/html-training/css/positioning/

Welcome to CSS! 欢迎使用CSS! It's fun, and sometimes aggravating. 这很有趣,有时还会加剧。 I hope you enjoy. 我希望你喜欢。

Try using %'s instead of fixed widths. 尝试使用%代替固定宽度。 What's happening is on smaller screens the menu is covered by your content block because the block is to big for the screen. 发生的是在较小的屏幕上,内容块覆盖了菜单,因为该块对于屏幕来说太大了。 To see what I mean open the site with your smartphone then adjust the size of your container down. 要了解我的意思,请使用智能手机打开网站,然后向下调整容器的大小。 You will see your menu appear when you refresh. 刷新时,您会看到菜单出现。 I have firefox on this laptop and the menu doesn't show for me either. 我在这台笔记本电脑上安装了Firefox,菜单也没有显示。

You should try adding the menu div to container and remove position absolute.I see too many divs so try using less divs. 您应该尝试将菜单div添加到容器中并删除绝对位置。我看到太多div,因此请尝试使用较少的div。 why do you need that cssmenu div? 为什么您需要该cssmenu div?

    <div id="container">
    <div id="menu">
    <div id="cssmenu">
    </div>
    </div>
    <div class="insta">
    </div>
      rest of content
    </div> end container

                .insta {
                color: #333333;
                width: 100%;
                margin-left: auto;
                margin-right: auto;
                -webkit-border-radius: 7px;
                -moz-border-radius: 7px;
                border-radius: 7px;
                -moz-box-shadow: 0 0 10px 0 #000;
                -webkit-box-shadow: 0 0 10px 0 #000;
                box-shadow: 0 0 10px 0 #000;
                background: #EDEDED;
                float:right;
                width:770px;
                }
                #container {
                overflow: auto;
                height: auto;
                width:920px;
                                    margin:0 auto;
                }
            #menu {
            float: left;
            margin-top: 25px;
            }

Hope this answer helps. 希望这个答案有帮助。

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

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