如下圖所示,請問 想把右側圖中 紅色塊3 調 到 黃色塊2的上方,加了 z-index 為什么沒有用,請幫忙看一下,HTML的代碼 如何調整,謝謝大家。

5.html 代碼如下
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#big-box{ width: 500px; height: 800px; border:1px solid #8a2be2; }
#a1 { width: 100px; height: 100px; background: aqua; }
#a2 {width: 200px; height: 200px; background:yellow; }
#a3 {width: 100px; height: 100px; background:red; }
#a4 {width:50px; height: 50px; background:pink; }
#a5 {width: 300px; height: 300px; background:peru; }
</style>
</head>
<body>
<div id="big-box">
<div id="a1">1</div>
<div id="a2">2</div>
<div id="a3">3</div>
<div id="a4">4</div>
<div id="a5">5</div>
</div>
</body>
</html>
4.html 代碼 如下:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#big-box{ width: 500px; height: 800px; border:1px solid #8a2be2; }
#a1 { width: 100px; height: 100px; background: aqua; }
#a2 {width: 200px; height: 200px; background:yellow; position:relative; float: left;z-index:1;}
#a3 {width: 100px; height: 100px; background:red; z-index:4; }
#a4 {width:50px; height: 50px; background:pink; position:relative; float: left; }
#a5 {width: 300px; height: 300px; background:peru; }
</style>
</head>
<body>
<div id="big-box">
<div id="a1">1</div>
<div id="a2">2</div>
<div id="a3">3</div>
<div id="a4">4</div>
<div id="a5">5</div>
</div>
</body>
</html>
uj5u.com熱心網友回復:
加個相對定位就行了uj5u.com熱心網友回復:
z-index 要與position已啟用,在有z-index的地方加個position:relative就行轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/271786.html
標籤:JavaScript
上一篇:那些大佬知道DateTimePicker組件 點擊里面選擇時間要第二天的零點,不是默認當天的日期和時間,也不是默認顯示在上面,要點擊選擇時間觸發的
