简体   繁体   中英

css - z-index not working

I have this:

<!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>

z-index of avatardiv not working in firefox. I can click on img in IE but can not click on it in FireFox.

any solution?

use position:relative property where you are using z-index, i hope it will work

    <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>

http://www.w3schools.com/cssref/pr_pos_z-index.asp

Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM