Previous Message
Next Message

Making a div with relative width?

Sent by Gunlaug_Sørtun on 28 April 2006 11:11


Asle Ommundsen wrote:
> http://odp.no/

> The problem is the 32em width on .attribution, it scales and works 
> good with browsers on windows (Firefox, Opera, IE6 and IE7), but on 
> Ubuntu i doesn't. The problem is that the following line of text wrap
>  into two lines, and it should really all be on only one line:

> <p>Hjelp til å bygge den største katalogen på nettet redigert av 
> mennesker.</p>

(Noen setter seg høye mål... :-) )

> I am trying to manage without using any width at all, beacause that 
> would solve the problem ones and for all, but I don't know how to do 
> it. Is it possible to make the width relative to the content of the 
> div so I don't have to specify any width any more? That is what I 
> want to do.

The proper way to do it is to make that div imitate a table. That's not
a problem in standard-compliant browsers, by adding...

div.attribution {width: auto; display: table;}

Add some left and right padding to the paragraph (<p>Hjelp til å
bygge...) so that table-simulation won't appear too tight, and it'll
look just fine.


However, IE/win doesn't understand 'display: table', so a width is
needed for that browser, like the one you have...

* html div.attribution {width: 32em;}

....and IE7 will need such a width too, so you'll have to pick your
favorite solution/hack that'll give it one.

Trim back the extra padding on the paragraph - for IE/win only, and that
should be it.

---

Note: it is also possible to make such a solution with floats, but it
require some complex positioning to make a flexible float center, so I
don't think that's the way to go on ordinary web pages.

regards
	Georg
-- 
http://www.gunlaug.no
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: