I've few images inside a scroll box and I need some text to be over that image. Number of images can be dynamic, it needn't be 6 in number and they have to be in horizontal scroll not vertical. Following is my code,
<style type="text/css">
.imgtext {
margin-left: -300px;
}
</style>
<div id="hcontainer" style="width: 600px;">
<div id="inner_container" style="overflow: auto; width: 2500px;">
<img src="1.jpg" width="400px" height="200px" /><span class="imgtext">My new_1 text</span>
<img src="2.jpg" width="400px" height="200px" /><span class="imgtext">My new_2 text</span>
<img src="3.jpg" width="400px" height="200px" /><span class="imgtext"> My new_3 text</span>
<img src="4.jpg" width="400px" height="200px" /><span class="imgtext"> My new_4 text</span>
<img src="5.jpg" width="400px" height="200px" /><span class="imgtext">My new_5 text</span>
<img src="6.jpg" width="400px" height="200px" /><span class="imgtext">My new_6 text</span>
</div>
</div>
As you can see the text is coming over the image, but the images are collapsing because of it, which doesn't look good. I've looked into solution of relative parent positioning and absolute child positioning, but I'm not allowed to modify divs style/css properties. So, using absolute and relative solution in div style wouldn't work! I'm allowed to play around with img
& span
tags and there css properties.
I'm okay with use of jquery/javascript which can move the text and place it on the corresponding image. But I'm not able to solve it by myself. can anyone help me with it?