On Mon, 30 Apr 2007, Skip Knox wrote:

>> You could use markup like
>> <div class="imgcaption"><div>caption text</div></div>
>> and set
>> div.imgcaption { width: 200px; }
>> div.imgcaption div { padding: 0 0.75em; }
>> (instead of the style="width: 200px" attribute).
> The trouble with this is that pictures across multiple pages will have
> unpredictable widths, so there's no way to set it in the stylesheet.

Yes, it gets awkward, but I'm afraid it's the only way. (You can set the 
widths in the stylesheet, but each img element would need its own setting, 
so no _general_ stylesheet alone could handle this.)

>> There are probably easier ways too. If you rely on browsers applying
>
>> "shrink-to-fit" width to floated elements by default (and you
> probably
>> could), you could leave div.imgcaption width unspecified and just set
> the
>> padding.
> If I leave the width unspecified then there's no way to ensure that it
> stays within the width of the image.

You're right, I was too eager in my optimism. Using just a floated div 
works if the caption text is not longer than the width of the image, 
but if it's longer, the shrink-to-fit width of the div is determined by 
the text length.

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to