css - z-index 导致在 div 内滑动

标签 css html z-index

出于某种原因,当我为图像设置 z-index:0 时,div 显示正确,但可以在父 div 中向上/向下滑动。但是,如果我有 z-index:-100,图像就会消失,不再滑动。

有什么方法可以让 z-index:0 图像不在父 div 中四处移动?我希望将图像锁定到位。谢谢!

frame_th img 是我想要锁定的 div。

.frame_th {
    width: 220px;
    margin: 0px auto;
}
.frame_th img {
    position: absolute;
    z-index: -100;
    margin: 30px 0 0px 26px;
}

最佳答案

尝试给 .frame_th 一个 position: relativeoverflow: hidden,以及 .frame_th img z-索引:0。这应该使图像在父 div 中正确定位而不会滑动。

关于css - z-index 导致在 div 内滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13673299/

相关文章:

javascript - 如何在不关闭其他 Accordion 的情况下逐步折叠/展开 Accordion ?

javascript - 在 Chrome 中使用目标 "blob:"将 anchor href 设置为 "_blank"URL 的问题

html - jQuery 手机 : Get data passed to page via changePage

css - Chrome 和谷歌地图的 z-index 堆叠问题

Javascript:修改函数以动态创建表

css - 在可滚动但不滚动图像的 div 上创建叠加层(带有 bg 图像)

html - CSS z-index 无法正确响应 - 子菜单隐藏在内容下方

html - 找出我页面中的 z-index

jquery - 滚动 div 内的固定位置

javascript - 使该步骤充当 <input type ="number"> 中的指南