我有一个导航栏,它固定在屏幕的顶部。此导航栏是 position: fixed;
,但它呈现在我的内容下方,即 position: relative;
。我怎样才能避免这种情况?
最佳答案
您需要将 #navbar
的 z-index
property 的 value 设置为较高的值足够了,例如:
#navbar {
z-index: 999999; /* needs to be higher than the content's z-index (if defined) */
}
只是为了确保它位于顶部 或其他所有内容的前面。
关于HTML 相关内容在固定内容上呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47498337/