私はこのCSSを持っています:
<style type="text/css">
.chart {
position: relative;
width:300px;
height:85px;
padding:0;
margin:0;
background:url("prova2.png") center bottom no-repeat;
z-index:1;
}
.chart div{
float:left;
font-size:13px;
text-align:center;
}
.chart .green{
position:absolute;
left: 50px;
top:50px;
height:35px;
width:50px;
background: green;
}
</style>
そしてこのhtmlコード:
<div class="chart">
<div style="margin-left:15px;">
<b>-2</b><br />
0.1234
</div>
<div style="margin-left:27px;">
<b>-1</b><br />
0.1234
</div>
<div style="margin-left:27px;">
<b>MEDIA</b><br />
0.1234
</div>
<div style="margin-left:18px;">
<b>+1</b><br />
0.1234
</div>
<div style="margin-left:27px;">
<b>+2</b><br />
0.1234
</div>
<div class="green"></div>
</div>
ご覧のとおり、透明度のあるprova2.pngを使用しています。
これは画像です:
コードの結果は次のとおりです。
緑の長方形が画像の上にあることがわかりますが、私はz-indexを使用し、div(画像を背景として)にはz-index:1があるため、理由はよくわかりません。
なぜ緑のdivが上にあるのですか?
背景として色を動的に設定する必要がありますが、(。png画像の...png画像の残りの部分は透明です)垂直線を表示する必要があるため、緑色のdivの上の線と、透明なパーツ。
誰かが私を助けてもらえますか?
ありがとう!