如圖所示,右側 的塊4 為什么算在這么奇怪的位置,它不是應該在塊3的下側嗎,為什么
跑到了塊2的右側?

以上圖片代碼如下:
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熱心網友回復:
另個貼子不是已經問了么……你請問問題時描述完整,你完整的效果并沒說
a1~a5的樣式中,加入position: absolute;z-index:值;值越大,就浮在上面,想怎么弄怎么弄了。float去掉
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/272113.html
標籤:JavaScript
上一篇:視頻決議
