html - 查看图像重叠导航栏的问题
问题描述
我遇到了一个问题,即肖像与我的导航栏重叠。我一直在环顾四周,试图找到解决办法,但没有运气。我已经尝试过 z-index,但遗憾的是根本没有用。
我的部分代码:
/*Navbar CSS*/
.topNavMain,
.topNavMain ul {
margin: 0;
padding: 0;
background: rgba(227, 232, 237, 0.40);
color: #5f6f81;
list-style: none;
text-transform: none;
text-decoration: none;
width: 100%;
font-weight: 300;
font-family: 'Lato', Arial, sans-serif;
line-height: 60px;
z-index: 999 !important;
}
/*img class CSS*/
.imgPortrait {
width: 80%;
z-index: -999;
overflow: hidden;
}
<section id="aboutMe" class="contentS">
<div class="container">
<div class="row">
<div class="col slideIn margin-fix">
<h2 class="contentT">About me</h2>
<p class="shortText">Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br> Fusce mollis pretium felis id ultricies. Sed libero risus, volutpat vel rhoncus et, auctor non ipsum. <br> Praesent sollicitudin nibh nisl, et sagittis nulla ornare at.</p>
</div>
<div class="col slideIn2">
<img src="img/portrait.jpg" alt="" class="imgPortrait img-fluid"></img>
</div>
</div>
</div>
</section>
我的问题的屏幕截图: 单击此处。
解决方案
只是一个简单的修复,您需要将 z-index 应用于div
包含导航的内容,而不仅仅是ul
.
#navDiv {
z-index: 1;
}
推荐阅读
- javascript - this.setData 不是反应中的函数
- c++ - 使用 C++ 预处理器自动生成重复代码
- android - Activity.recreate() 导致 Butterknife 绑定失败 - 视图变为空
- java - 当我更改按钮的图标然后使用阻塞命令(从套接字获取信息)时,在我得到响应之前我看不到图标的变化
- go - 通过 Visual Studio Code 的 GoLang 扩展:导入不起作用。从常规命令行构建和测试正常
- php - 在 PHP 中验证远程文件
- java - 如何在 OpenShift 上部署 Java Spring MVC 项目
- php - 当我尝试检索大列内容时如何修复“允许的内存大小”
- azure-devops - 在 Azure DevOps (VSTS) 中链接到文件的特定版本中的一行代码
- c# - 如何改变射击路径?(2D)