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

时间:2017-01-16 07:55:05

标签: html css navigation

我现在正在处理自适应导航菜单,以便我的网页可以与不同的平台兼容。我按照这里的步骤进行了操作:http://www.w3schools.com/howto/howto_js_topnav.asp/但是当我缩小窗口时我无法保持相同的位置(当我的页面在宽屏幕上时,我使菜单始终保持在顶部)。如何使它保持在顶部,因为每个导航栏都是为了?

1 个答案:

答案 0 :(得分: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;