CSS的z-index屬性是做什麼用的,CSSz-index屬性

來源:互聯網
上載者:User

CSS的z-index屬性是做什麼用的,CSSz-index屬性

CSS的z-index屬性是做什麼用的:
建議:儘可能的手寫代碼,可以有效提高學習效率和深度。
在網頁製作中,可能有這樣的需求,就是讓幾個層重疊在一起,並且可以指定順序,這時候使用z-index屬性是個不錯的選擇。
但是此屬性僅作用於[position屬性值為relative、[absolute或fixed的對象,不會作用於視窗控制項,如select對象。
執行個體代碼如下:

 

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><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>

 

結合以上代碼的表現可以得出以下結論:
1.對象的position屬性值必需是relative、absolute或者fixed。
2.z-index屬性值大的對象位於z-index屬性值小的對象之上。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=4702

更多內容可以參閱:http://www.softwhy.com/divcss/

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.