Previous Message
Next Message

Auto-sizing a containing div?

Sent by Bruno Fassino on 2 January 2004 11:11

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable

Josh Galun wrote:
> I am trying to wrap an IMG in two borders: 1 immediately=20
> around the IMG, and then another spaced 20px out from the=20
> IMG. I was going to do this by creating the first border on=20
> the IMG itself, and the second on a containing DIV. You can=20
> see the effect I am going for, and my current styles (inline) at:
> However, the way I am currently doing it, I need to set the=20
> width on the containing DIV, otherwise the containing DIV=20
> will become 100% of the page width. Is there any way to make=20
> the DIV autosize based on the size of the IMG inside it?

Hi Josh,
In my opinion the only way to easily get what you want is to use a =
cell table to wrap your image, instead of a div.
Alternatively you can try to add:
	display: table;
to your containing div. This will probably work in some modern browsers
(Mozilla, Opera, maybe others), but IE/Win does not support it.  For =
you could take advantage of its "ability" to enlarge divs to wrap the
content, and feed (only to it) a small fixed width, like 1px. =20
With some hacks this may work, but all is going to be much more complex =
necessary, so I think this is one case where a table is a much easier
solution. But I know that many will disagree :), so I'm really =
interested in
hearing a better solution!


Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

css-discuss [EMAIL-REMOVED]]
Supported by --

Previous Message
Next Message

Message thread: