<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Computed vs Cascaded Style</title>
	<atom:link href="http://ajaxian.com/archives/computed-vs-cascaded-style/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/computed-vs-cascaded-style</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Tue, 16 Mar 2010 23:51:05 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: RobR</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-272024</link>
		<dc:creator>RobR</dc:creator>
		<pubDate>Sun, 15 Mar 2009 17:29:09 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-272024</guid>
		<description>I had a similar problem the other day requiring the computed style in px not the currentStyle or style value. The following function seems to correctly convert the style to px and ems and also handles styles in % and child elements where the parent is in % but the child is set to &quot;auto&quot;.

http://www.strictly-software.com/CSSStyleObject.asp</description>
		<content:encoded><![CDATA[<p>I had a similar problem the other day requiring the computed style in px not the currentStyle or style value. The following function seems to correctly convert the style to px and ems and also handles styles in % and child elements where the parent is in % but the child is set to &#8220;auto&#8221;.</p>
<p><a href="http://www.strictly-software.com/CSSStyleObject.asp" rel="nofollow">http://www.strictly-software.com/CSSStyleObject.asp</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morgan Knicely</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-254878</link>
		<dc:creator>Morgan Knicely</dc:creator>
		<pubDate>Mon, 03 Sep 2007 15:28:07 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-254878</guid>
		<description>I&#039;ve found Dean Edwards&#039; snippet very useful, it&#039;s helped reduce my IE dev time.  I use the MooTools library, so I re-factored the snip as a MooTools extension:

&lt;code&gt;
Element.extend({
  /**
   * Calculates the absolute measurement of the style e.g. &quot;pixels&quot;.
   * Fails on % values, original value is returned instead.
   * @param {String} property : CSS property to be read
   */
  getStylePx: function(property){
    var PX = /^\d+(px)?$/i;
    var value = this.getStyle(property);
    if (PX.test(value)) {return parseInt(value);}
    if (value.indexOf(&quot;%&quot;) &gt; -1) {return value;}
    var style = this.style.left;
    var runtimeStyle = this.runtimeStyle.left;
    this.runtimeStyle.left = this.currentStyle.left;
    this.style.left = value &#124;&#124; 0;
    value = this.style.pixelLeft;
    this.style.left = style;
    this.runtimeStyle.left = runtimeStyle;
    return value;
  }
});
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I&#8217;ve found Dean Edwards&#8217; snippet very useful, it&#8217;s helped reduce my IE dev time.  I use the MooTools library, so I re-factored the snip as a MooTools extension:</p>
<p><code><br />
Element.extend({<br />
  /**<br />
   * Calculates the absolute measurement of the style e.g. "pixels".<br />
   * Fails on % values, original value is returned instead.<br />
   * @param {String} property : CSS property to be read<br />
   */<br />
  getStylePx: function(property){<br />
    var PX = /^\d+(px)?$/i;<br />
    var value = this.getStyle(property);<br />
    if (PX.test(value)) {return parseInt(value);}<br />
    if (value.indexOf("%") &gt; -1) {return value;}<br />
    var style = this.style.left;<br />
    var runtimeStyle = this.runtimeStyle.left;<br />
    this.runtimeStyle.left = this.currentStyle.left;<br />
    this.style.left = value || 0;<br />
    value = this.style.pixelLeft;<br />
    this.style.left = style;<br />
    this.runtimeStyle.left = runtimeStyle;<br />
    return value;<br />
  }<br />
});<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253339</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Mon, 30 Jul 2007 23:54:20 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253339</guid>
		<description>It is a mess generally. Here is what I have been dealing with today:

Internet Explorer returns (as defined in the Stylesheet)
fontSize: 110% and lineHeight: 1.4

Firefox returns pixel values for both. While this is OK for the font size, it means that you cannot get lineHight from one element and assign it to another element...

P.S.: Nice trick, Dean. Have to remember that one.</description>
		<content:encoded><![CDATA[<p>It is a mess generally. Here is what I have been dealing with today:</p>
<p>Internet Explorer returns (as defined in the Stylesheet)<br />
fontSize: 110% and lineHeight: 1.4</p>
<p>Firefox returns pixel values for both. While this is OK for the font size, it means that you cannot get lineHight from one element and assign it to another element&#8230;</p>
<p>P.S.: Nice trick, Dean. Have to remember that one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc Grabanski</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253326</link>
		<dc:creator>Marc Grabanski</dc:creator>
		<pubDate>Mon, 30 Jul 2007 16:13:08 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253326</guid>
		<description>Dean, you are crazy - in a good way. I would have never thought of converting em to the pixel equivalent.

I needed this function a few days ago when I was trying to calculate the width of an element and having no success in getting it to work cross browser.   Thanks Dean.</description>
		<content:encoded><![CDATA[<p>Dean, you are crazy &#8211; in a good way. I would have never thought of converting em to the pixel equivalent.</p>
<p>I needed this function a few days ago when I was trying to calculate the width of an element and having no success in getting it to work cross browser.   Thanks Dean.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabian Jakobs</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253316</link>
		<dc:creator>Fabian Jakobs</dc:creator>
		<pubDate>Mon, 30 Jul 2007 11:38:14 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253316</guid>
		<description>@Dean. Thanks a lot. I think I&#039;ve got it now. Nice code BTW.</description>
		<content:encoded><![CDATA[<p>@Dean. Thanks a lot. I think I&#8217;ve got it now. Nice code BTW.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dean Edwards</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253315</link>
		<dc:creator>Dean Edwards</dc:creator>
		<pubDate>Mon, 30 Jul 2007 11:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253315</guid>
		<description>@Fabian - MSIE6+ has special pixelLeft/Width/Height etc properties. They represent the current pixel value of the equivalent style setting. So, if you have style.width=8em then style.pixelWidth would return the pixel equivalent. MSIE also supports an override style called runtimeStyle. Setting properties on runtimeStyle overrides all other style properties.

This trick works by setting style.left and then getting MSIE to convert it by calling style.pixelLeft. To stop the element moving around the screen when we do this, we set runtimeStyle.left with the current left value. After we&#039;ve done the conversion we set everything back to the way it was.

Clear?</description>
		<content:encoded><![CDATA[<p>@Fabian &#8211; MSIE6+ has special pixelLeft/Width/Height etc properties. They represent the current pixel value of the equivalent style setting. So, if you have style.width=8em then style.pixelWidth would return the pixel equivalent. MSIE also supports an override style called runtimeStyle. Setting properties on runtimeStyle overrides all other style properties.</p>
<p>This trick works by setting style.left and then getting MSIE to convert it by calling style.pixelLeft. To stop the element moving around the screen when we do this, we set runtimeStyle.left with the current left value. After we&#8217;ve done the conversion we set everything back to the way it was.</p>
<p>Clear?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Giammarchi</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253311</link>
		<dc:creator>Andrea Giammarchi</dc:creator>
		<pubDate>Mon, 30 Jul 2007 10:27:37 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253311</guid>
		<description>If value could be negative I suppose this test is quite better, am I wrong?
var PIXEL = /^\-?\d+(px)?$/i;</description>
		<content:encoded><![CDATA[<p>If value could be negative I suppose this test is quite better, am I wrong?<br />
var PIXEL = /^\-?\d+(px)?$/i;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabian Jakobs</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253308</link>
		<dc:creator>Fabian Jakobs</dc:creator>
		<pubDate>Mon, 30 Jul 2007 08:57:38 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253308</guid>
		<description>Unfortunately the link is broken. Would like to have seen some words by Dean how his code is supposed to work.</description>
		<content:encoded><![CDATA[<p>Unfortunately the link is broken. Would like to have seen some words by Dean how his code is supposed to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joggink</title>
		<link>http://ajaxian.com/archives/computed-vs-cascaded-style/comment-page-1#comment-253307</link>
		<dc:creator>joggink</dc:creator>
		<pubDate>Mon, 30 Jul 2007 07:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2617#comment-253307</guid>
		<description>I use the first function in one of my own side projects, and for the font-size property IE returns 10pt, FF returns 12px and Opera returns caption...
Too bad you can&#039;t read from the style proporty of an object.</description>
		<content:encoded><![CDATA[<p>I use the first function in one of my own side projects, and for the font-size property IE returns 10pt, FF returns 12px and Opera returns caption&#8230;<br />
Too bad you can&#8217;t read from the style proporty of an object.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
