Webscaped.com

Min-Max Width support in IE6

Sunday May 11th, 2008
Comment Icon 2 comments

To be able to get around this, you could create a css expression, such as detailed here.

CSS expressions are a bit dodgy, and are slower to run then javascript.

You can also manipulate javascript a bit easier, deciding exactly when and where to run it. CSS files should be kept fairly basic, things like this should be moved into a javascript file you can use across other sites.

Even then though, I’ve had issues with IE6 freezing when running the javascript.

After some fiddling, it seemed to work better if the units I used when setting the width with “container.style.width” were the same as used in your css file.

	window.onload = loadAll();
	window.onresize = minMaxWidthFix;
 
	function minMaxWidthFix(){
		var container = document.getElementById("outer");
 
		if(document.body.clientWidth >= 1200)
		{
			container.style.width = "120em";
			return true;
		}
 
		if(document.body.clientWidth <= 800)
		{
			container.style.width = "80em";
			return true;
		}
 
		container.style.width = "100%";
 
	}
 
	function loadAll(){
		//Other IE functions you want to run, eg fixing li:hover support
		minMaxWidthFix();
	}

So if your having problems running min/max scripts, try changing your container.style.width value to em’s, px, cm’s, percent or whatever unit you’re using for the container element.

2 comments

  1. Antti

    There is a rather simple CSS ‘hack’ available to accommodate this: http://www.dustindiaz.com/min-height-fast-hack/ The same above should work with min-width as well.

  2. Michael

    Indeed that fixes a min-width/height, but it doesn’t allow for a scaling layout. I was looking to get a container have a min width, and scale up to a max width depending on window size. I probably should have mentioned what I was trying to achieve :)

Leave a Reply

Copyright © Michael Adams     powered by WordPress

    RSS Feed HTML 4.01 Valid CSS Valid