473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Caption sized to width of /floated/ image?

I've tried to apply something along the lines of
http://www.spartanicus.utvinternet.i...d_to_image.htm
to a floated span containing an image & caption, but I can't find
anything that'll work in IE - floating seems to break it.

Can it be done without having to specify each image's width explicitly?

The best related info I could find was posted here a few days ago, but
doesn't seem to work with floats in IE, unless I'm just having another
too late night.
http://groups.google.co.uk/groups?hl...oogle%2BSearch

--
Michael
m r o z a t u k g a t e w a y d o t n e t
Jul 21 '05 #1
6 2017
Hi,
I've tried to apply something along the lines of
http://www.spartanicus.utvinternet.i...d_to_image.htm
to a floated span containing an image & caption, but I can't find
anything that'll work in IE - floating seems to break it.

I tried to get spartanicus' proposal working, but like you discovered,
IE isn't very cooperative... I had luck; our graphic-department wanted
fixed-sized divs, therefore it's no longer my problem :-)
But I fear this problem can not be solved (without scripting).

Chris
Jul 21 '05 #2
Michael Rozdoba <mr**@nowhere.invalid> wrote:
I've tried to apply something along the lines of
http://www.spartanicus.utvinternet.i...d_to_image.htm
to a floated span containing an image & caption, but I can't find
anything that'll work in IE - floating seems to break it.
Floating should break it, css 2.1 specifies that floated elements should
use a shrink to fit method when no width is specified (IE has always
used a shrink to fit method for floats).

width:inherit on the caption's block level container won't help here,
IIRC only specified widths can be inherited (not computed widths).
Can it be done without having to specify each image's width explicitly?


Specifying a width on the containing block is always best, anything else
is sub optimal.

--
Spartanicus
Jul 21 '05 #3
Chris Leipold wrote:

[ http://www.spartanicus.utvinternet.i...d_to_image.htm
& floats ]
I tried to get spartanicus' proposal working, but like you discovered,
IE isn't very cooperative... I had luck; our graphic-department wanted
fixed-sized divs, therefore it's no longer my problem :-)
But I fear this problem can not be solved (without scripting).


Indeed. Thanks for the feedback.

--
Michael
m r o z a t u k g a t e w a y d o t n e t
Jul 21 '05 #4
Spartanicus wrote:
Michael Rozdoba <mr**@nowhere.invalid> wrote:

I've tried to apply something along the lines of
http://www.spartanicus.utvinternet.i...d_to_image.htm
to a floated span containing an image & caption, but I can't find
anything that'll work in IE - floating seems to break it.

Floating should break it,


I wondered but didn't check - it was too late into the morning.
css 2.1 specifies that floated elements should
use a shrink to fit method when no width is specified (IE has always
used a shrink to fit method for floats).

width:inherit on the caption's block level container won't help here,
IIRC only specified widths can be inherited (not computed widths).


I think I tried that along with a few less rational stabs in the dark.
Can it be done without having to specify each image's width explicitly?

Specifying a width on the containing block is always best, anything else
is sub optimal.


Hm. Shame. I hate having to inline styles, even if it is only width. At
least in this case I can. In other situations this would rule out static
pages & require program code, albeit with a choice of client or server side.

--
Michael
m r o z a t u k g a t e w a y d o t n e t
Jul 21 '05 #5
*Michael Rozdoba* <mr**@nowhere.invalid>:

I've tried to apply something along the lines of
http://www.spartanicus.utvinternet.i...d_to_image.htm
to a floated span containing an image & caption, but I can't find
anything that'll work in IE - floating seems to break it.


span {width: expression(this.firstChild.width);}

where the 'span' contains the 'img' as its first child, would do, but is
of course not correct CSS. In an intranet it may be tolerable, but
shouldn't be used out on the Web.

Is it a gallery of images with captions or some images illustrating a
larger text inline?

Some test-pages of mine:
<http://webdesign.crissov.de/temp/css-d/captions-zoe.html>,
<http://webdesign.crissov.de/temp/ciwas/image-captions-table.html>.

--
No sig today, my .sig has gone away
The divider stands forlorn, a symbol of the dawn
No sig today, it seems a common sight
But people reading by don't know the reason why
Jul 21 '05 #6
Christoph Paeper wrote:
*Michael Rozdoba* <mr**@nowhere.invalid>:

I've tried to apply something along the lines of
http://www.spartanicus.utvinternet.i...d_to_image.htm
to a floated span containing an image & caption, but I can't find
anything that'll work in IE - floating seems to break it.

span {width: expression(this.firstChild.width);}

where the 'span' contains the 'img' as its first child, would do, but
is of course not correct CSS. In an intranet it may be tolerable, but
shouldn't be used out on the Web.


Agreed. Interesting to know about the options though. I assume that's an
IE thing? Or does Moz allow similar access to the DOM within CSS? BTW
Does the above rely on the img element in the html having the width
specified, or does it actually calculate it from the image's file?
Is it a gallery of images with captions or some images illustrating a
larger text inline?
The latter, as part of a small website for a course of mine.
Some test-pages of mine:
<http://webdesign.crissov.de/temp/css-d/captions-zoe.html>,
<http://webdesign.crissov.de/temp/ciwas/image-captions-table.html>.


Thanks :)

--
Michael
m r o z a t u k g a t e w a y d o t n e t
Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: puzzled | last post by:
Okay, so my subject sounds a bit crass. As much as I'd like to totally embrace css and avoid "deprecated" usage, sometimes the deprecated stuff is so much easier and more effective. Plus, it at...
8
by: Wally | last post by:
I would like to have an image with a caption displayed below it. The size of the image will vary. The caption should not extend beyond the width of the image. How can I cause the text of the...
2
by: aqualizard | last post by:
I have made and image with a caption using CSS, but I am hoping someone can show me how to do it better. By better I mean less HTML, and hopefully have it work with any sized image where I do not...
0
by: mephraim | last post by:
I have a page at (view in IE): http://rmc2.dev.leepfrog.com/ie_fix_me/index.html that has an image floated right outside of a main content div that looks like: <img src="blah" style="float:...
3
by: Roy Reed | last post by:
I found a script that converts image alt text to a caption which I've tried to modify for my needs: function addCaption(imgElem) { var captionElem = document.createElement("div");...
6
by: Hacking Bear | last post by:
Hi, I still don't quite fully understand how to handle mixing border/margin pixel width with percentage width. In the example below, I want to place side-by-side two DIV boxes inside a box....
8
by: Ben Bacarisse | last post by:
After finding a page on an existing site that was not being displayed correctly by IE7, I have boiled the problem down to the following simple example: http://bsb.me.uk/tmp/bug.html With...
11
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/Demo/photo%20block%20experiments.html I've ended up with what seems like a rather complex structure for what I thought would be a somewhat simple...
7
by: Peter Parker | last post by:
Could someone show me how to limit caption width to image width dynamically (image width is not known in advance) if that's possible? I was thinking of using Javascript to get the image width which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.