silverorange labs

Comments

Steven Garrity -

I originally thought that this didn't work with absolute positioning — putting elements positioned to the right against the window edge rather than the page edge. I was totally wrong. I even filed a bug in Mozilla's bugzilla, where I was appropriately shot down.

The problem was that I was putting the <span class="code">min-width</span> on the <span class="code">body</span> element, when it should really be on the <span class="code">html</span> element.

I've updated the post above accordingly.

Aaron Schaap -

It's sad that IE doesn't understand this feature, but nice that many others do.

Does know of a hack / alternative way that could get this desired affect in IE?

Jaykul -

There's a very simple hack. Make a standard 'spacer' graphic, 1 pixel by 1 pixel, transparent gif. Then, place it on your web page, inside the divs you want to force to a specific size, something like this:

img src="spacer.gif" width="300" height="1"

Actually, you can use height="0", but it breaks in netscape 4.x if you do that (kind-of strange)

Nathan Hall -

I haven't tested this yet but could you add the image spacer graphic in a CSS rule, say as a background property? it would be nice to add the graphic as a CSS rule so screen readers are not contronted with images used for formatting purposes.

If this cannot be achieved I think it would be good to add an alt tag to the spacer image.

Brad Bulger -

I've just been trying to make this work, and an image inside a div does not seem to do anything to force the div to be a certain minimum width - so that if you made your browser narrower than 300 pixels, for instance, the div and its contents would stretch past the right edge of the browser. The div always seems to only be as wide as the browser window.

This is without having specified any other properties for the div, I should add, and in Mozilla on OS X.

Adriano Castro -

I've tried all 'tricks' suggested here and none seem to work for my design. IE doesn't seem to like it being forced to a minimum width. Anyone?

AD

Adriano Castro -

The answer to all our IE prayers comes directly from Svend's site. Check it out... It worked perfectly for me:

http://www.svendtofte.com/code/max_width_in_ie/

AD

Mihkel -

I use div positioned absolute (75% width) and a simple table (100% width)inside it and again a div (300px width) inside that table. So it is almost as min-width but still not free of "design" tables. So it is no solution, but little more optimzed than with spacer.gif which would need a html request to download and has to rendered as a picture.

Mihkel -

<div class="main">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><div class="spacer"></div>
Content content content
</td>
</tr>
</div>

Svend -

The max/min-width/height hack does work. But I wouldn't recommend it, unless you have some DOM/JavaScript experience. It's a particularly nasty hack, with some faults (which can be remedied, though I don't go into that in the linked to site).

Just be careful, and test it carefully, before using it :)

bzend -

"[...]in normal browsers, even the most beautiful flexible-width CSS layouts get wacky when the window gets too narrow."

"[...]when you shrink your browser window too narrow (200~300px), elements start to wrap, and this generally get jumbled[...]"

I see this wrapping aspect of CSS-positioned pages as an advantage over the table layout. IMO, this min-width obsession is just a remnant from the <table> way of thinking. Even if IE supported it, I don't think I would be using it, as I prefer to have a page wrapped than a horizontal scroll bar (is there anything more annoying than a horizontal scroll bar?).

So, if narrow windows are an issue, there are ways to produce a meainingful page layout with CSS even with a narrow window (and without a horiz. scroll bar!). This is not a weak side of CSS, these conditions were simply not taken into consideration when developing the pages given here.

Kev -

This will work for IE and FireFox

<div style="min-width:180px">
<div style="width:180px">
some long content here that would wrap normally
</div>
</div>

Alan -

The tip to set min-width on html instead of body helped me fix a problem with safari.. thanks! However, then in gecko browsers it applied the width but did not show a horizontal scrollbar.. so now I check the user agent and set min-width on html for safari, else body.

Scott -

Why not just consider using the minmax.js that Andrew Clover wrote and can be found on doxdesk.com? It seems to do alright for IE6 Win although there are times it doesn't fire properly when the window is being resized. To fix, slightly move the window frame and it will catch up.

Post a Comment: Wide-body CSS

Email addresses are not displayed with your comment and will not be shared.
Allowed tags are: <em>, <strong>, <code> and <a href="url">. All other tags will be displayed as plain text.