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

Docker installation of MySQL (8 and 5.7)

This article will introduce how to use Docker to ...

Method for comparing the size of varchar type numbers in MySQL database

Create a test table -- --------------------------...

Detailed explanation of JQuery selector

Table of contents Basic selectors: Level selector...

JavaScript Composition and Inheritance Explained

Table of contents 1. Introduction 2. Prototype ch...

mysql data insert, update and delete details

Table of contents 1. Insert 2. Update 3. Delete 1...

HTML table tag tutorial (7): background color attribute BGCOLOR

The background color of the table can be set thro...

The best solution for resetting the root password of MySQL 8.0.23

This method was edited on February 7, 2021. The v...

What you need to know about responsive design

Responsive design is to perform corresponding ope...

Solve the problem of inconsistent front and back end ports of Vue

Vue front and back end ports are inconsistent In ...

MySQL stored procedure method example of returning multiple values

This article uses an example to describe how to r...

How to prevent duplicate submission in jquery project

In new projects, axios can prevent duplicate subm...

Solution to the problem of installing MySQL compressed version zip

There was a problem when installing the compresse...

Understand the basics of Navicat for MySQL in one article

Table of contents 1. Database Operation 2. Data T...

VUE render function usage and detailed explanation

Table of contents Preface The role of render Rend...