我有这个:
<!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/