我想讓我的文字出現在我的背景圖像上。我試圖玩z-index
和定位,但似乎無法做到。如何使文字顯示在圖像頂部
這裏是我的HTML:
<div id="float-left">
<div id="triangles">
<img src="img/trianglebackground.png" id="tripic">
</div>
<div id="float-left-text">
<img src="img/portrait.png" id="port">
</div>
</div>
這裏是CSS我目前:
#tripic {
z-index:1;
height: 550px;
width: 500px;
text-align: center;
opacity: 0.2;
position: relative;
}
#float-left {
float: left;
/*background: url('img/trianglebackground.png') no-repeat center;*/
background-size:500px 550px;
background-color: #03C9A9;
height: 550px;
width: 50%;
z-index:0 ;
position: relative;
}
#float-left-text{
text-align: center;
z-index: 100;
position: absolute;
}
#port {
height: 200px;
width: 125px;
}
眼下,整個#floatlefttext
部分是背景圖像的下方,而我會把它想在上面。我試圖使用background-image
,但我不確定這將是獲得我想要的結果的最佳方式。任何建議將是偉大的,謝謝!
哇,非常感謝!這是一個非常有用和徹底的答案。我會閱讀這篇文章,看起來很有希望。再次感謝! – ohconfusedone
隨時,很高興我可以幫助:) – malinantonsson