<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JamesMarquez.com &#187; javascript</title>
	<atom:link href="http://www.jamesmarquez.com/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jamesmarquez.com</link>
	<description>filipino web applications developer and designer</description>
	<lastBuildDate>Sat, 29 May 2010 04:03:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Standard compliant CSS Min Width and Max Width for IE6</title>
		<link>http://www.jamesmarquez.com/css-compliant-min-width-and-max-width-for-ie6.html</link>
		<comments>http://www.jamesmarquez.com/css-compliant-min-width-and-max-width-for-ie6.html#comments</comments>
		<pubDate>Mon, 28 Jul 2008 03:31:10 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS Solutions and Tips]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.jamesmarquez.com/?p=11</guid>
		<description><![CDATA[It&#8217;s not actually a pure CSS tricks/hacks, as we all know, IE6 doesn&#8217;t support CSS minimum and maximum width but we can achieve those properties to work using DOM manipulation.
I used jQuery library to make my DOM manipulation simple and easy.
First step, get the CSS min width and max width value defined in the CSS [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not actually a pure CSS tricks/hacks, as we all know, IE6 doesn&#8217;t support CSS minimum and maximum width but we can achieve those properties to work using DOM manipulation.</p>
<p>I used <a title="jQuery" href="http://www.jquery.com/">jQuery</a> library to make my DOM manipulation simple and easy.</p>
<p>First step, get the CSS min width and max width value defined in the CSS file, so that the resizing will still dependent on the CSS properties. I use &#8220;container&#8221; as my div tag ID that wraps up all the html elements.</p>
<pre>  var min_width	= parseInt($('#container').css('min-width'));
  var max_width	= parseInt($('#container').css('max-width'));
</pre>
<p>Here is the function that will resize the container:<span id="more-11"></span></p>
<pre>  function resizeContainer()
  {
    var old_width = document.body.offsetWidth;
    var new_width = old_width;

    if (old_width &gt; max_width)
    {
      new_width = max_width - 40 + 'px';
    }
    else if (old_width &lt; min_width)
    {
      new_width = min_width - 40 + 'px';
    }
    else
    {
      new_width = '96%';
    }

    $('#container').css({width: new_width});
  }
</pre>
<p>Call the resizer function on page load to make the layout render base on the browser&#8217;s width.</p>
<p>On window resize, call the resizer if the min_width and max_width has values. There&#8217;s no reason to resize if the &#8220;container&#8221; in CSS file doesn&#8217;t have min-width and max-width values. Here&#8217;s the code to resize the container on window resize:</p>
<pre>  $(window).resize(function()
  {
    if (min_width!='undefined' &amp;&amp; max_width!='undefined')
    {
      resizeContainer();
    }
  });
</pre>
<p>To wrap it all, here&#8217;s my complete js code:</p>
<pre>$(document).ready(function()
{
  // get the CSS container width values
  var min_width	= parseInt($('#container').css('min-width'));
  var max_width	= parseInt($('#container').css('max-width'));

  // resize the container on page load
  resizeContainer();

  $(window).resize(function()
  {
    if (min_width!='undefined' &amp;&amp; max_width!='undefined')
    {
      resizeContainer();
    }
  });

  function resizeContainer()
  {
    var old_width 	= document.body.offsetWidth;
    var new_width	= old_width;

    if (old_width &gt; max_width)
    {
      new_width = max_width - 40 + 'px';
    }
    else if (old_width &lt; min_width)
    {
      new_width = min_width - 40 + 'px';
    }
    else
    {
      new_width = '96%';
    }

    $('#container').css({width: new_width});
  }
});
</pre>
<p>Save the js code on external file or include the code on the header tag of your document but use  conditional comments so that only IE6 will execute it.</p>
<pre>
&lt;!--[if IE 6]&gt;
&lt;script src="ie6.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;![endif]--&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmarquez.com/css-compliant-min-width-and-max-width-for-ie6.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
