我有以下HTML(Plunker Example):地點DIV比其它DIV和圖像
<div class="first">
<img src="http://placehold.it/350x150">
</div>
<div class="second">
Lorem Ipsum ...
</div>
我需要放置第二DIV在第一DIV的一部分,因此我使用:
body {
text-align: center;
}
.first {
background-color: orange;
z-index: 100;
}
.first img {
display: block;
margin: 0 auto;
}
.second {
background-color: red;
margin: -80px 0 auto;
z-index: 200;
}
奇怪的是第二個DIV中的文本出現在圖像上方,而不是第二個DIV。紅色應該在圖像上,因爲文字是...
有沒有人知道如何解決這個問題?
添加位置:相對。第二。 https://css-tricks.com/almanac/properties/z/z-index/ https://jsfiddle.net/10L7fad9/ – sinisake