|
Posted by Ben C on 11/01/07 23:13
On 2007-11-01, MangroveRoot <zcukpkn02@sneakemail.com> wrote:
> I've looked for tutorials on how to do this for some years,
> with no success.
>
> Most of the time, I'm a good boy and only use <TABLE> (etc)
> to format tabular data.
>
> However, there remains one thing that <TABLE> does excellently
> that I have yet to find a way to do using solely CSS:
>
> Put a block of text *in a box*,
> which box sizes itself to the size of the *content*,
> not to some arbitrary fixed width or some percentage of the window.
[...]
> Surely CSS can do this; how?
You need a "shrink-to-fit" box.
Apart from tables and table cells, floats, inline-blocks and
absolutely/fixed positioned boxes are shrink-to-fit.
Out of that lot floats are probably the simplest.
Put your content in a float, with auto width, and the float will shrink
to fit the content (according to CSS 2.1, in any half-decent
browser, and even in IE).
Of course you can't centre a float so I hope that's not your next
question.
[Back to original message]
|