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.

------=_NextPart_000_000D_01C3D12C.1839C030
Content-Type: text/plain;
	charset="utf-8"
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:
> http://www.galun.com/testPic.php
> 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 =
single
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 =
IE/Win
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 =
than
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!

Bruno

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

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

------=_NextPart_000_000D_01C3D12C.1839C030--
Previous Message
Next Message

Message thread: