html - CSS 固定顶部菜单导航在某些项目下
问题描述
我在我的网站上遇到了一个问题:我试图修复上面的菜单,现在当我滚动浏览网站时,所有的标题和段落都在菜单上:
这是固定顶部菜单的 HTML
<div class="topnav" id="myTopnav">
<a href="#" class="active">Home</a>
<a href="#">About</a>
<a href="#">Menu1</a>
<a href="#">Menu2</a>
</div>
这是固定顶部菜单的 CSS
.topnav {
background-color: #333;
overflow: hidden;
position: fixed; /* Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%; /* Full width */
}
所以问题是:我怎样才能使它成为一切之上?
解决方案
.topnav {
background-color: #333;
overflow: hidden;
z-index: 100; /* or 999 */
position: fixed; /* Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%; /* Full width */
}
推荐阅读
- c# - 刚体碰撞层
- javascript - querySelector 中的 Javascript Varialbe 返回 null
- json - 如何编组和解组 x509.Certificate 到/从 JSON?
- angular - 如何在 recaptcha 中获取最终用户的 IP
- selenium - 在 BrowserStack 中运行多个自动化测试时,第一个测试成功运行,但不会为剩余的会话创建会话
- c - 为什么单链表打印“NULL”?
- java - com.sun.jdi.invocationexception 方法 getOne(id) Hibernate + Spring MVC + JPA Repository
- vba - 如何访问和切换两个非默认联系人文件夹?
- azure-ad-b2c - Azure AD B2C 单点注销
- python - webjobs json数据到熊猫数据框