How to solve the problem of absolutely positioned elements mysteriously disappearing or being blocked in IE6/7

How to solve the problem of absolutely positioned elements mysteriously disappearing or being blocked in IE6/7
1. When the width of the adjacent floating layer of the absolutely positioned layer is not equal to the width of the parent layer, and the float is not cleared, the display is consistent in IE6/7 and FF;
2. When the width of the adjacent floating layer of the absolute positioning layer is not equal to the width of the parent layer, when the float is cleared, IE6/7 does not display the absolute positioning layer, but FF does;
3. When the width of the adjacent floating layer of the absolute positioning layer is equal to the width of the parent layer, and the floating is not cleared, IE6 does not display the absolute positioning layer, but IE7/FF displays it;
4. When the width of the adjacent floating layer of the absolute positioning layer is equal to the width of the parent layer, when the float is cleared, IE6/7 does not display the absolute positioning layer, but FF does;

The solution to this BUG is very simple. Just make sure that the absolutely positioned layer is not placed next to the floating layer. There is also an even simpler method, which is to add a blank div between the absolutely positioned element and other elements.
Let's take a look at the phenomenon where absolutely positioned elements mysteriously disappear and are blocked. First, let's understand the several positioning features involved:
1. The default z-index value of a relatively positioned element is 0.
2. When two relative positioning appear at the same time, the z-index of the code later takes precedence.
3. The child follows the z-index set by the parent; if the child sets absolute positioning and z-index, it can break through the parent to display. See the following code:

Copy code
The code is as follows:

<div style=”position:relative; background:#FF0000; width:200px; height:100px;”>
<div style="position:absolute; background:#FFFF00; width:49px; height:50px; left:106px; top:310px; z-index:100"></div>
</div>
<div style=”position:relative; background:#000000; width:200px; height:100px;”></div>
<div style=”position:relative; background:#9900FF; width:200px; height:100px;”></div>

Code explanation: There are three adjacent relatively positioned layers above. A layer with absolute positioning relative to the first layer is added. In theory, this absolutely positioned element is above the three relatively positioned elements. However, it is not displayed in reality. Trying to set the z-index value also has no effect.
The solution to this bug on the Internet is generally to use a hack to make B a negative value to reduce the level of B in IE. However, this method creates a new IE bug when the z-index is negative. According to the characteristics of positioning, this IE bug can be avoided.
On the surface, the lower layer covers the upper absolutely positioned layer. In fact, the lower layer covers the absolutely positioned parent layer. You only need to set the z-index of the parent layer to be larger than that of the layer behind it.

<<:  Example code for implementing a hollow mask layer with CSS

>>:  Detailed explanation of the process of docker packaging Python environment

Recommend

Introduction to MySQL statement comments

MySQL supports three types of comments: 1. From t...

How to deploy MySQL 5.7 & 8.0 master-slave cluster using Docker

> Deploy MySQL 5.7 cluster master & slave ...

A brief discussion on how to choose and combine div and table

Page layout has always been my concern since I st...

How to use bar charts in Vue and modify the configuration yourself

1. Import echart in HTML file <!-- Import echa...

Linux disk space release problem summary

The /partition utilization of a server in IDC is ...

How to develop Java 8 Spring Boot applications in Docker

In this article, I will show you how to develop a...

Detailed explanation of vue.js dynamic components

:is dynamic component Use v-bind:is="compone...

How to batch generate MySQL non-duplicate mobile phone number table example code

Preface In many MySQL test scenarios, some test d...

How to use Dayjs to calculate common dates in Vue

When using vue to develop projects, the front end...

In-depth understanding of MySQL various locks

Table of contents Lock Overview Lock classificati...

How to let DOSBox automatically execute commands after startup

Using DOSBox, you can simulate DOS under Windows ...

How to enable Swoole Loader extension on Linux system virtual host

Special note: Only the Swoole extension is instal...

Installation tutorial of mysql 8.0.11 compressed version under win10

This article shares the installation tutorial of ...