I’m working on a site that places an image in a div and beneath the image is an <p> tag with some text in it. The pictures can be 150px wide or 200px wide but the <p> tag should not be wider then the image because then it messes up the layout. So I’m not sure what to do, the width of the images is dynamic so I can’t put a width on anywhere, so I may have to resort to javascript to get the width of the image and put that width on the <p> tag but javascript isn’t really my strong suit so I’m hoping for a simple css solution.
Here’s a bit of code so you guys can see how it looks.
<li>
<div class="container_movie">
<img src="images/category/movie/super-8-cover.jpg"/>
<p> super8<br/>
22-07-’11 <span class="day_countdown">// 11 days</span></p>
</div>
</li>
Also I know the code isn’t perfect yet, I’m still testing a lot.
If you decide use javascript you can use something like this (code is very ugly and it’s meant only for illustrating the idea):