2017-01-16 79 views
0

我现在正在开发一个响应式导航菜单,以便我的页面可以与不同的平台兼容。我遵循了这里的步骤:http://www.w3schools.com/howto/howto_js_topnav.asp/,但是当我缩小窗口时,我无法使它保持原来的位置(当我的页面在宽屏幕上时,菜单始终保持在顶部)。如何让它保持在每个导航栏的顶部?如何使响应式导航菜单保留在页面的顶部?

+0

位置:固定的(如果你想让它滚动时呆在那里,偶)或立场:绝对的(如果你只是想让它在顶部该页面,但不在浏览器窗口的顶部); top:0;左:0;正确:0; – deadfishli

+0

谢谢。但是,当我将位置更改为固定并单击该图标时,整个酒吧会变形,看起来不像酒吧.. –

+0

它看起来像这样。 https://i.imgsafe.org/c810d924b2.png –

回答

2

你可能要定位添加到您的导航栏:

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;