I'm working on a site which will have a variety of captioned images. These images will change over time and the widths will vary. I want the caption to always be the same width as the image without having to state the actual image width.
I found a JQuery script on this forum provided by Marc Audet ("CSS - div width depending on image size above" March 30, 2011) which seems to work. I changed the class names to match my own, but otherwise the script should be the same as he provided.
$(document).ready(function() {
theWidth = $(".photo_caption img").css('width');
$(".photo_caption").css('width',theWidth);
});
However, there are two things that I have questions about.
1-None of the CSS styling on .photo_caption works. I can give it a purple 4 px border, add float right, add 100px of padding, but none of these things happen. Why isn't the styling applying? I also wondered if this problem relates to problem number two below.
2-I'd like the surrounding paragraph text to wrap around the image and caption. I've tried adding a float left on the .photo_caption div but so far nothing has worked.
Here's a link to the site. It's the middle column, "HIGH SCHOOL SENIORS, APPLY NOW FOR THE NBCAF ART SCHOLARSHIP," to which I'm referring.
www.laurafigdesign.com/nbcaf
As a very novice designer I appreciate any suggestions to solve these problems.
Thanks, Laura