<?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>Cynical Optimism &#187; Javascript</title>
	<atom:link href="http://evan.verstory.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://evan.verstory.com</link>
	<description>my views on life and the world</description>
	<lastBuildDate>Tue, 13 Apr 2010 02:38:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Emulate max-width / max-height for Internet Explorer (no extra work needed!)</title>
		<link>http://evan.verstory.com/2009/07/emulate-max-width-max-height-internet-explorer-no-extra-work-needed/</link>
		<comments>http://evan.verstory.com/2009/07/emulate-max-width-max-height-internet-explorer-no-extra-work-needed/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 22:29:13 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://evan.verstory.com/?p=278</guid>
		<description><![CDATA[As I&#8217;m sure many of you know, Internet Explorer (even IE8) completely ignores the max-width and max-height css properties. I did some Googling but unfortunately all of the stuff I found was for manually setting the max-width/max-height or some similar buffoonery. I&#8217;ve written a nice Javascript (uses jQuery) function that you can include in your [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m sure many of you know, Internet Explorer (even IE8) completely ignores the max-width and max-height css properties. I did some Googling but unfortunately all of the stuff I found was for manually setting the max-width/max-height or some similar buffoonery. I&#8217;ve written a nice Javascript (uses <a href="http://jquery.com/">jQuery</a>) function that you can include in your head tag to emulate proper detection of the max-width and max-height css attributes without doing any extra work after that (so long as it&#8217;s in the head of the content you&#8217;re loading with max-width/max-height attributes). Feel free to use it but please keep my copyright statement if you don&#8217;t mind!</p>
<p>Cheers and happy designing:</p>
<pre class="syntax-highlight:javascript">
function css_emulateMaxWidthHeight() {
/* (c) Evan Roberts - 7/10/2009
www.GoWFB.com - Wholesale Furniture Brokers
Everyone is free to use/mdoify this but please keep the copyright statement!
*/

	$(&#039;img&#039;).each(function() {		

		if( $(this).css(&#039;max-width&#039;) != &#039;none&#039; || $(this).css(&#039;max-height&#039;) != &#039;none&#039; ) {

			max_width = $(this).css(&#039;max-width&#039;).replace(/[^0-9]/g, &#039;&#039;);
			max_height = $(this).css(&#039;max-height&#039;).replace(/[^0-9]/g, &#039;&#039;);		

			if( $(this).width() &gt; max_width || $(this).height() &gt; max_height ) {
				if( (max_width / $(this).width()) &lt; (max_height / $(this).height()) ) {
					$(this).css(&#039;height&#039;, Math.round($(this).height() * (max_width / $(this).width())));
					$(this).css(&#039;width&#039;, max_width);
				} else {
					$(this).css(&#039;width&#039;, Math.round($(this).width() * (max_height / $(this).height())));
					$(this).css(&#039;height&#039;, max_height);
				}

			}
		}
	});
}

$(document).ready(function() {

	css_emulateMaxWidthHeight();

});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://evan.verstory.com/2009/07/emulate-max-width-max-height-internet-explorer-no-extra-work-needed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
