javascript - 为什么 z-index 没有效果?
问题描述
我需要文字在图像上方,所以我设置z-index
为 10,图像设置为 5。
文字在Navbar
.
function ProductList2(props: OrganizationList2) {
return (
<div>
<div className={styles.container1}>
<Navbar />
<img
src="/Olovka_Studio_gyűrű_v2.png"
width="100"
height="140"
className={styles.img1}
/>
.container1 {
background-color: #12341b;
position: relative;
height: 38vw; /*543/1440*/
}
.img1 {
position: absolute;
right: 11vw; /*159/1440*/
top: 0px;
z-index: 5;
height: 38vw;
width: 24vw; /*372/1440*/
}
.container { /* <------------------ Inside Navbar*/
display: flex;
margin-left: 8vw; /*128/1440*/
margin-right: 8vw; /*430/1440*/
justify-content: space-between;
max-height: 88px;
z-index: 10;
}
解决方案
没有元素的元素z-index
不起作用position
尝试:
.div-with-z-index {
position: relative /* Relative doesn't change the position of the element itself. */
}
推荐阅读
- sql - 之前的累积和,之后的累积和
- python - 有没有办法在使用 ** 运算符时即时对变量进行类型转换?
- python - 有什么方法可以使用python以递增顺序在文件中添加数据
- npm - 当我尝试使用 npm 将 node-sass 作为 package.json 脚本运行时,为什么会收到错误消息?
- flutter - 在 audioplayers dart 包中出现编译时错误
- ios - SwiftUI - 在嵌套视图上使用不同的转换
- flutter - Flutter 中的动画浮动操作按钮
- excel - 动态字段编号 - Excel VBA
- cmake - CMake Visual Studio 工作流程
- android - 线程“主”java.lang.reflect.InvocationTargetException 中的异常 - Ktor 应用程序