CSS Z-index layer overlap order

Source: Internet
Author: User

The div floats above another div:

"http://www.w3.org/1999/xhtml">"Content-type"Content="text/html; charset=gb2312"/> <title> Absolute Positioning relative positioning </title> <style>. fj1 {position:absolute;            width:150px;            height:150px; border:1px Solid # the; Background: #999;            }. zj1 {position:relative;            width:100px;            height:100px;            border:1px solid #F00;            Background: #FFF; Z-index:1; }    </style>class="fj1">I was on the bottom of the occurrence of a large--large with the disc included</div> <divclass="zj1">I float on top</div> </div></body>

div CSS Z-index layer overlap order

div layer, span layer and other HTML tag layer overlap Order Style z-index, usually we use less, but also will inevitably encounter CSS z-index use. Next DIVCSS5 introduces Z-index from basic to set object stacking order, overlapping order, from basic grammar to application case tutorial to explain learning z-index.

First, Z-index grammar and structure

Z-index with specific numbers

Such as:
DIV{Z-INDEX:100}
Note : The value of Z-index is not the same as the unit.

The higher the number of z-index, the more forward, and the value must be both integers and positive numbers (integers with positive numbers).

Ii. Z-index conditions of Use

Z-index is used only when using the absolute positioning Position:absolute property condition. Usually we have different object boxes that overlap in different order, and we just want to z-index the style attributes.

Three, Z-index application case

To conveniently observe the Z-index style properties, we set up 3 div boxes, set different CSS background colors, set the same CSS height, CSS width. Set the background color to black, red, and blue, respectively. CSS width is 100px,css height of 50px

1. Case CSS Code

    1. /* www.divcs5.com Z-index instance */
    2. . divcss5{position:relative;}
    3. . divcss5-1,.divcss5-2,.divcss5-3
    4. {Width:100px;height:50px;position:absolute;}
    5. . Divcss5-1{z-index:10;background: #000; left:10px;top:10px}
    6. . Divcss5-2{z-index:20;background: #F00; left:20px;top:20px}
    7. . Divcss5-3{z-index:15;background: #00F; left:30px;top:30px}

2. HTML code Snippet

    1. <div class="divcss5-1"></div>
    2. <div class="divcss5-2"></div>
    3. <div class="divcss5-3"></div>

CSS Z-index layer overlap order

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.