How to troubleshoot div layer Adjustment Z-index Property Invalid method

Source: Internet
Author: User
This article mainly introduced the P layer adjustment z-index attribute Invalid reason analysis and the solution method, needs the friend can refer to the next

Z-index invalid

In the process of doing, found a very simple but many people should encounter the problem, set the Z-index property is invalid. In CSS, only through the code to change the hierarchy, this property is Z-index, to let Z-index function has a small premise, that is, the element position attribute if Relative,absolute or fixed.

1. The first case (Z-index regardless of how high the setting is):

There are three conditions in which this happens:

1, the parent tag position attribute is relative;
2, problem label no position attribute (not including static);
3. The problem label contains the float (float) attribute.

The Eg:z-index hierarchy does not work, the float will invalidate the Z-index, the code is as follows:

<p style= "position:relative; z-index:9999 ">    </p>

There are three solutions (any one can):

1, position:relative changed to Position:absolute;
2, floating elements add position attributes (such as relative,absolute, etc.);
3, remove the float.

2. The second case

IE6, the level of performance is sometimes not to look at the z-index of the sub-tag, but to look at the hierarchy of the parent tag of the first relative property of the entire DOM tree.

Eg:ie7 and IE6 have the same bug, the reason is very simple, although the picture of P current father level is very high (1000), but because Dad's father is not useful, poor 9999 such a strong child no doomed Ah! , the code is as follows:

<p style= "position:relative" ><p style= "position:relative; z-index:1000 "><p style=" Position:absolute; z-index:9999 ">  </p></p> </p>

Workaround: In the first relative attribute plus a higher level (Z-INDEX:1), the code is as follows:

<p style= "position:relative; Z-index:1 ">  <p style=" position:relative; z-index:1000 ">  <p style=" Position:absolute; z-index:9999 ">  </p>  </p>  </p>

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related recommendations:

About CSS3 rem (setting font size) parsing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.