471,887 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Can a div's width expand to fit content's width?

Hi

I've created a banner with a drop-shadow using a div - there's a mock-
up at http://tinyurl.com/6n7czu . The only problem is that the way
I've done it, I have to specify the width of the div - if I don't, it
renders with a width of 100%. Is there any way of making the width fit
the text it encloses (plus padding), and so that it expand
automatically if you add more text?

Dave
Apr 8 '08
50 7024
VK
On Apr 10, 8:35 pm, Dave Rado <dave.r...@dsl.pipex.comwrote:
Floats don't meet my requirement for reasons discussed earlier in the
thread (the boxes have to be shrink-to-fit *and* centred). I've got it
working using tables though.
AFIAK you cannot reliably do it by CSS alone because of different
quirks on different browsers. It also very difficult to do because of
official by very silly treatment of overflow:auto. It is being taken
as kind of overflow:remainder, so "take all space what rest" while it
should be, as the name implies, "take exactly how much space you need
to accommodate the current content but not a pixel more".

I would stay with one cell table to keep things cross-browser
compatible and reliable.
Jun 27 '08 #51

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bob Imperial | last post: by
3 posts views Thread by Kai Rosenthal | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

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.