-1
A
回答
0
這裏是所有你需要
div {
height: 100px;
width: 100px;
background: #ccc;
position: absolute;
top: 0;
left: 0;
}
.div1{
background: #f00;
}
.div2{
top: 30px;
}
.div_child{
background: #3a2525;
left: auto;
right: 0;
width: 50px;
z-index: 1;
}
<div class="div1">
1
<div class="div_child">
child
</div>
</div>
<div class="div2">
2
</div>
0
幾乎任何可能與CSS3。然而div 1中的元素需要分開才能工作。如果它在div 1內,它會將div 1拖動到其中。你會得到更大的靈活性,如果側DIV是在它自己的
但是對於你的具體的例子,你會需要這樣的東西:
HTML:
<div class="top"></div>
<div class="bottom"></div>
<div class="side"></div>
CSS:
.top {
width: 90%;
margin-left: 10%;
height: 200px;
height: 250px;
background: red;
}
.bottom {
width: 90%;
height: 200px;
height: 250px;
margin-left: 5%;
background: grey;
margin-top: -150px;
}
.side {
width: 20%;
height: 200px;
height: 250px;
margin-left: 78%;
background: yellow;
margin-top: -300px;
}
Working CodePen也在這裏:https://codepen.io/WebDevelopWolf/pen/mBLqxm
0
不知道爲什麼會這樣的作品,但它可能對你會有所幫助:
#div1, #div2{
width: 100%;
height: 400px;
}
#div1{
background-color: red;
position: relative;
}
#div2{
background-color: green;
}
#div2{
margin-left: 50px;
margin-top: -300px;
position: relative;
}
#div1 > div{
background-color: yellow;
position: absolute;
width: 200px;
height: 200px;
right: 0;
top: 50px;
z-index: 2;
}
.as-console-wrapper{ display: none !important;}
<div id="div1">
DIV 1
<div>INSIDE DIV 1</div>
</div>
<div id="div2">
DIV 2
</div>
相關問題
- 1. 一個HTML IMG堆疊2周的div
- 2. 堆疊擴展DIV
- 3. 堆疊div元素
- 4. CSS - 堆疊的DIV佈局
- 5. 滾動時堆疊div
- 6. Div標籤互相堆疊
- 7. Div與div(HTML/CSS)重疊?
- 8. Html css重疊div
- 9. HTML和CSS堆疊框
- 10. 垂直堆疊html元素
- 11. 防止Div的向下堆疊
- 12. 如何在彼此之上堆疊Div
- 13. Div互相重疊 - HTML
- 14. 閃存重疊的HTML div
- 15. HTML中的重疊div
- 16. 從右下角開始堆疊div div123s
- 17. div堆疊/佈局與CSS或javascript
- 18. jQuery的AJAX問題,堆疊的div
- 19. 堆疊DIV和水平對齊
- 20. 並排呈現並堆疊的Div
- 21. 堆疊和轉移的div響應
- 22. Div在響應式設計中堆疊
- 23. 如何使用Flexbox Grid堆疊div?
- 24. 堆疊格在另一個DIV
- 25. Div和Jquery Slider的堆疊問題
- 26. 重疊父div的HTML/CSS div
- 27. 堆疊/重疊UITableViewCells
- 28. 堆疊HTML元素的順序
- 29. HTML表格沒有正確堆疊
- 30. Html CSS圓角幫助堆疊元素
我認爲這將是越容易黃色的將是'div的孩子2' – Swellar
你有什麼實現?這看起來很簡單,如果你不給「DIV 2」提供任何Z-index,那麼你可以使用絕對/固定定位將'ELEMENT INSIDE DIV 1'放置在'DIV 2'之上。 –
我覺得這個問題已經被StackOverflow問了太多次了:你嘗試過搜索嗎? – Terry