怎么讓多個DIV重合
2 回答

白板的微信
TA貢獻(xiàn)1883條經(jīng)驗 獲得超3個贊
在內(nèi)層設(shè)為 absolute 的時候,外層必須設(shè)為 relative,否則外層默認(rèn)為 static。這樣外層有滾動條的時候,內(nèi)層 div 才會隨著外層滾動。
12345678910 | <style type= "text/css" > div { border : 1px solid #000 ;} #outer { width : 500px ; height : 500px ; overflow : auto ; position : relative ;} #outer div { position : absolute ;} #inner 1 { width : 300px ; height : 100px ; top : 250px ; left : 20px ;} #inner 2 { width : 200px ; height : 150px ; top : 150px ; left : 150px ;} #inner 3 { width : 250px ; height : 150px ; top : 230px ; left : 200px ;} #inner 4 { width : 250px ; height : 100px ; top : 320px ; left : 170px ;} #makeScroll { width : 10px ; height : 10px ; top : 1000px ; left : 1000px ;} </style> |
1234567 | < div id = "outer" > < div id = "inner1" ></ div > < div id = "inner2" ></ div > < div id = "inner3" ></ div > < div id = "inner4" ></ div > < div id = "makeScroll" ></ div > </ div > |

波斯汪
TA貢獻(xiàn)1811條經(jīng)驗 獲得超4個贊
默認(rèn)時就是relative,你一定要設(shè)置成重疊的話用margin的負(fù)數(shù)可以實(shí)現(xiàn)你要的效果,最好先每個DIV加個底色或不一樣的邊框,更會排除混淆
- 2 回答
- 0 關(guān)注
- 1073 瀏覽
添加回答
舉報
0/150
提交
取消