简体   繁体   中英

Why does the pink box not overlap in IE6?

It does it for every other browser ( I think ).

http://www.webdevout.net/test?01H&raw

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <title>Test</title>
    <style type="text/css">
* { overflow: visible; }
#precedence { float: right; height: 60px; width: 50px; background: pink; margin-bottom: -10px; margin-right: 20px; overflow: visible; }
#first { height: 50px; border: 1px dashed blue; background: white; margin-bottom: -10px; z-index: 100; position: relative; overflow: visible; }
#second { height: 50px; border: 1px dashed red; background: white; z-index: -1; overflow: visible; }
   </style>
  </head>
  <body>
    <div id="first">
      <div id="precedence"></div>
    </div>
    <div id="second"></div>
  </body>
</html>

Add position: relative; to the box ( #precedence ). This will force IE to put it in the layering calculations it does. It will then realize that it is not contained inside it's parent ( #first ) and will overflow properly.

This is the tested example: http://jsfiddle.net/s4W52/

It works in IE6, IE7, IE8, Firefox 2.0.x/3.0.x, so it should work in others too

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