You are here: Re: possible to make div width match content? « HTML « IT news, forums, messages
Re: possible to make div width match content?

Posted by Spartanicus on 04/01/06 19:27

"Stan R." <stan.remove@bremove.lz.hmrprint.com> wrote:

>I'm trying to make a <div>, but from what I've observed, be default, it
>trys to consume the most width possible.

That would be "width:0", not much point I would think.

>What 'm have trouble doing is make it take the /minmal/ space possible,
>like a table without any specified width.

That would be the table-layout:auto width mechanism:
http://www.w3.org/TR/CSS21/tables.html#width-layout

>What I'm really getting at is I'm trying to have a simple <div> with
>left aligned text but be centered on the screen.
>
>I've tried many variants of the following:
>
><center>
><div style="text-align: left">
>Text that should be Left aligned, but centered on the screen.
></div>
></center>
>
>
>So it looks like this
>
>| Text that should be Left aligned, but centered on |
>| the screen. |
>
>^----- screne border -------------------------------------------------^

A table without specified width would extend the width of the table to
100% of it's containing block, and then wrap the text within it, not
what you've drawn above.

To achieve what you've drawn you'd need

<p style="width:25em;margin-left:auto;margin-right:auto">Text that
should be Left aligned, but centered on the screen.</p>

--
Spartanicus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация