简体   繁体   English

在移动设备上拉起页面时将导航标题保持在顶部

[英]Keeping Navigation Header at Top When Page Pulled Up on Mobile

I've noticed on sites like The New Yorker that when on mobile if you scroll to the very top and continue to scroll upwards the navbar stays firmly attached to the top of the window.我在《纽约客》等网站上注意到,在移动设备上,如果您滚动到最顶部并继续向上滚动,导航栏会牢牢固定在窗口顶部。 On my site, the navbar stays connected to the rest of the content when I scroll up and continue past the body of the page.在我的网站上,当我向上滚动并继续浏览页面正文时,导航栏会与其余内容保持连接。 How would I go about emulating what The New Yorker does.我将如何模仿《纽约客》的做法。 I have looked at their page's css but can't seem to tell what gives that functionality.我查看了他们页面的 css,但似乎无法说明是什么赋予了该功能。 Any help would be appreciated.任何帮助,将不胜感激。

setting the position:fixed and top:0 to the navbar should work, although after that you will have to determine the height occupied by the navbar and give your body content padding set to that height to have a neat display.position:fixedtop:0设置为导航栏应该可以工作,但之后您必须确定导航栏占据的height并将您的正文内容padding设置为该高度以进行整洁的显示。 Please check this link : Why the paragraph is hidden behind navbar however navbar comes first in html source?请检查此链接: 为什么该段落隐藏在导航栏后面,但导航栏在 html 源代码中排在第一位?

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

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