简体   繁体   English

如何使响应式导航菜单保留在页面顶部?

[英]How to make a responsive navigation menu remain at the top of a page?

I'm now working on a responsive navigation menu so that my page will be compatible with different platforms. 我现在正在使用响应式导航菜单,以便我的页面将与不同的平台兼容。 I followed the steps here: http://www.w3schools.com/howto/howto_js_topnav.asp/ but I couldn't make it remain the same position when I shrank the window (I made the menu always remain at the top when my page is on a wide screen). 我在这里按照以下步骤操作: http : //www.w3schools.com/howto/howto_js_topnav.asp/,但是当我缩小窗口时,我无法使其保持在相同的位置(我将菜单始终保持在顶部页面在宽屏上)。 how to make it remain at the top as every navigation bar is meant to? 如何使其保持在每个导航栏所指的顶部?

You probably have to add positioning to your navigation bar: 您可能必须在导航栏中添加位置:

position: fixed; /* if you want it to stay there even when scrolling */
position: absolute; /* if you just want it at the top of the page, but not at the top of your browser window */
top: 0;
left: 0;
right: 0; 

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

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