Home  >  Article  >  Web Front-end  >  What is the z-index attribute of CSS used for_html/css_WEB-ITnose

What is the z-index attribute of CSS used for_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:40:031576browse

What is the z-index attribute of CSS used for:

In web page production, there may be a need to overlap several layers. Together, and the order can be specified, using the z-index attribute is a good choice at this time.

However, this attribute only acts on objects whose position attribute value is relative, absolute, or fixed, and will not act on window controls, such as select objects.

The example code is as follows:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.51texiao.cn/" /><title>蚂蚁部落</title><style type="text/css">.index1, .index2, .index3{  position:absolute;  width:150px;  height:100px;}.index1{  z-index:1;  background-color:#663}.index2{  z-index:2;  top:50px;  left:50px;  background-color:#303}.index3{  z-index:3;  top:100px;  left:100px;  background-color:#090}</style></head><body><div class="index1">index1</div><div class="index2">index2</div><div class="index3">index3</div></body></html>

Combined with the performance of the above code, the following conclusions can be drawn:
1. The value of the position attribute of the object must be relative, absolute or fixed.
2. Objects with a large z-index attribute value are located above objects with a small z-index attribute value.

The original address is: http://www.51texiao.cn/div_cssjiaocheng/2015/0519/1895.html

The most original address is: http://www.softwhy.com/ forum.php?mod=viewthread&tid=4702

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn