|
Posted by Ben C on 10/20/06 09:32
On 2006-10-20, X l e c t r i c <Xlectric@webtv.net> wrote:
> Ben C wrote:
>
> "Absolutely positioned boxes are shrink-to-fit if they have auto width,
> but not if you try to centre them with auto margins."
>
> Yes, I've been trying out what you've posted and that is the result that
> I get.
And this is what the spec (CSS 2.1) says, in different words. It's in
section 10.6.4.
> My question is this:
>
> Is there a way to shrink-to-fit a block level box without using absolute
> positioning ?
> You know, so the width of the box conforms to the width of the
> content, like a table.
You can also use a float. You can't centre floats, but neither can you
centre shrink-to-fit abs pos.
You can also use display: inline-block, and you can centre those too
just by making the container "text-align: center". This would be
preferable to the table solution I posted earlier, except that FF
doesn't support display: inline-block. Opera and Konqueror do.
For the sake of completeness, the other ways to do it are display:
table, display: table-cell or position: fixed.
Navigation:
[Reply to this message]
|