だから私は画像を持っています、私は画像の上に重ねられた透明な背景を持つテキストボックスを持っています(参考までに、アイテムの価格とそれが販売されているかどうかが含まれています)。テキストボックスが画像の幅に「収まる」ようにしたいと思います。現在、テキストは画像よりも幅が広くなっています。幅を調整してみましたが、幅を縮小してボックスを画像の上から移動するだけのようです。
ここに私が作成しようとしているものがあります。テキストの幅が画像と同じであることに注意してください。 http://imgur.com/zKzjIyF
ボックス内の赤いボックスは、左側の最初の項目、ベストの女の子にあります。
HTML:
<div class="date-container">
<div class="date-heading" style="display: block;">Friday, Oct 11, 2013</div>
<div class="items-purchased-container">
<DIV style="position: absolute; top:10px; left:355px; width:200px; height:25px">3</span> items purchased</p>
</div>
<div class="total-spend-container">
<div class="product">
<img src="https://theory.alluringlogic.com/api/v1/productvariation/3/1058.jpg?preset=XS" alt="" />
<div class="description">
<p>Sex shirt in sparkly black <span class="price">Price $500</span>
</p>
</div>
</div>
<div class="product">
<img src="https://theory.alluringlogic.com/api/v1/productvariation/3/1058.jpg?preset=XS" alt="" />
<div class="description">
<p>Sex shirt in sparkly black <span class="price sale">Sale Price $500</span>
</p>
</div>
</div>
CSS:
body {
background:#00000;
text-align:center;
}
.product {
display:inline-block;
position:relative;
margin-right:10px;
vertical-align:top;
}
.product img {
display:block;
max-width:100%;
}
.description {
position:absolute;
background:rgba(255, 255, 255, 0.75);
top:60%;
;
text-align:center;
width:100%;
}
.description span {
display:block;
margin-top:10px;
padding:5px;
}
.sale {
background:red;
}