html - css - z-index 不工作

标签 html css firefox

我有这个:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <title>Untitled</title>

    <style>
    .avatardiv{width:48px;height:48px;z-index:20}
    .avatardiv a{width:48px;height:48px}
    .postdiv{width:100%;margin-top:-48px;z-index:10}
    </style>

</head>

<body>

<div class="avatardiv"><a href="http://google.com"><img src="" /></a></div>
<div class="postdiv">test test test test test test test test test test ....</div>

</body>
</html>

avatardiv 的 z-index 在 firefox 中不工作。我可以在 IE 中点击 img,但在 FireFox 中无法点击它。

有什么解决办法吗?

最佳答案

在你使用 z-index 的地方使用 position:relative 属性,我希望它能起作用

    <style>
    .avatardiv{width:48px;height:48px;z-index:20;position:relative}
    .avatardiv a{width:48px;height:48px}
    .postdiv{width:100%;margin-top:-48px;z-index:10;position:relative}
    </style>

关于html - css - z-index 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18557093/

相关文章:

javascript - 嵌套的 div 和 'cannot set property ' innerHTML' of null' 错误

html - 将水平 ul 中的一个 li 对齐到另一个 li 下方

html - 我不知道如何摆脱空白

jquery - 多部分表单 POST 导致 Firefox 提示 JSON 保存

javascript - Angular JS ng-repeat 无法使用 PHP 数组获取输出

html - flexbox 模型中的自动内边距

javascript - 如果相应的文本区域被调整大小,如何保持按钮的位置?

javascript - 通过 id 传递元素适用于纯 javascript 但无法使用 jQuery

css - 显示内联 css 类或 id 定义的 Firefox 扩展?

html - 在 FireFox(所有浏览器)中滑出左侧导航/图像位置的正确 css?