This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > July 2007 > all div elements with the same (flexible) width





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author all div elements with the same (flexible) width
Kai Rosenthal

2007-07-30, 3:17 am

Hello,

I have two or more div elements which have the same min-width.
<div class="wrapper">
<div class="element01">text01</div>
<div class="element02">text02</div>
...
</div>

In a browser with normal font size all div elements have the same
width (min-width).

When I change the font size in browser some (but not all) div elements
become more largely than min-width. I get different widths for the div
elements.
How can I get the same width for all div elements with every font
size?

I don't want to work with tables.

Thanks for your hints, Kai

Andy Dingley

2007-07-30, 6:20 am

On 30 Jul, 08:10, Kai Rosenthal <kairosent...@tiscali.de> wrote:

> How can I get the same width for all div elements with every font
> size?


You should start by posting a URL to a working page, with the CSS --
not a fragment that's only the HTML and includes none of the relevant
CSS at all.

Otherwise it's a trivial exercise in CSS to set the width of the
<div>. Normally the initial value for the width property is "auto",
which causes its width to be calculated automatically on the basis of
the size of the content inside it. If you don't want that, just set it
to something else. Any of the length units will do this, but the usual
recommendation for em units rather pixels means that it works better
when text is re-sized.

Ben C

2007-07-30, 6:22 pm

On 2007-07-30, Andy Dingley <dingbat@codesmiths.com> wrote:
> On 30 Jul, 08:10, Kai Rosenthal <kairosent...@tiscali.de> wrote:
>
>
> You should start by posting a URL to a working page, with the CSS --
> not a fragment that's only the HTML and includes none of the relevant
> CSS at all.
>
> Otherwise it's a trivial exercise in CSS to set the width of the
><div>. Normally the initial value for the width property is "auto",
> which causes its width to be calculated automatically on the basis of
> the size of the content inside it.


Only for elements with shrink-to-fit widths (floats, tables, absolutely
positioned stuff). Otherwise auto width is set "greedily" so the outer
margin width of the element fills its available width completely.
Bergamot

2007-07-30, 6:22 pm

Kai Rosenthal wrote:
>
> How can I get the same width for all div elements with every font
> size?


A URL would be helpful, but generally speaking you can use % widths:
50% each for 2 columns, 33% for 3 columns, etc.

--
Berg
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews