<?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"
	>
<channel>
	<title>Comments on: Percentage rounding and sub pixel perfection</title>
	<atom:link href="http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/feed/" rel="self" type="application/rss+xml" />
	<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/</link>
	<description>Take the lead out...</description>
	<pubDate>Fri, 12 Mar 2010 05:14:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Stubbornella</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-9378</link>
		<dc:creator>Stubbornella</dc:creator>
		<pubDate>Fri, 06 Mar 2009 03:13:52 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-9378</guid>
		<description>Robert,

Check it out now.  The file size is even smaller, no gutters, and the lastUnit takes all remaining space, even in IE5.5 and 6! I'm so pleased.  :) Position relative on the lastUnit was the key.  

The only caveat now is that content being wider than the grid itself can cause a wrap.  For example an extra long word at really narrow widths.  In my tests it works perfectly for all normal scenarios.

The IE5.5 support is really key, because quirksmode in later versions of IE is much more like 5.5.

http://github.com/stubbornella/oocss/blob/3f0b8664446ee1f911d91370945cf948581ba484/css/grids.css

Let me know if you manage to break anything, good use cases are always welcome!

Cheers,
Nicole</description>
		<content:encoded><![CDATA[<p>Robert,</p>
<p>Check it out now.  The file size is even smaller, no gutters, and the lastUnit takes all remaining space, even in IE5.5 and 6! I&#8217;m so pleased.  <img src='http://agilewebmasters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Position relative on the lastUnit was the key.  </p>
<p>The only caveat now is that content being wider than the grid itself can cause a wrap.  For example an extra long word at really narrow widths.  In my tests it works perfectly for all normal scenarios.</p>
<p>The IE5.5 support is really key, because quirksmode in later versions of IE is much more like 5.5.</p>
<p><a href="http://github.com/stubbornella/oocss/blob/3f0b8664446ee1f911d91370945cf948581ba484/css/grids.css" rel="nofollow">http://github.com/stubbornella/oocss/blob/3f0b8664446ee1f911d91370945cf948581ba484/css/grids.css</a></p>
<p>Let me know if you manage to break anything, good use cases are always welcome!</p>
<p>Cheers,<br />
Nicole</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Gentel</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-9370</link>
		<dc:creator>Robert Gentel</dc:creator>
		<pubDate>Fri, 06 Mar 2009 00:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-9370</guid>
		<description>Nicole,

I wrestled with this issue for a couple of sleepless nights back then. Here were the results of my own research:

1) There's no way around the issue without feeding IE lesser values.
2) The more columns you have, the lower the value needs to be, making it pretty obscene if you have enough columns (I was shooting for a 12-column grid because of how divisible it is).

I, for one, like the gutters on the grid level, so if you had a solution with gutters I'd personally be interested in it. So far of all the CSS grids I've seen I've liked your fledgling one best, and am interested in building off it and extending it if I don't end up rolling my own.</description>
		<content:encoded><![CDATA[<p>Nicole,</p>
<p>I wrestled with this issue for a couple of sleepless nights back then. Here were the results of my own research:</p>
<p>1) There&#8217;s no way around the issue without feeding IE lesser values.<br />
2) The more columns you have, the lower the value needs to be, making it pretty obscene if you have enough columns (I was shooting for a 12-column grid because of how divisible it is).</p>
<p>I, for one, like the gutters on the grid level, so if you had a solution with gutters I&#8217;d personally be interested in it. So far of all the CSS grids I&#8217;ve seen I&#8217;ve liked your fledgling one best, and am interested in building off it and extending it if I don&#8217;t end up rolling my own.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stubbornella</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-9369</link>
		<dc:creator>Stubbornella</dc:creator>
		<pubDate>Fri, 06 Mar 2009 00:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-9369</guid>
		<description>Hi Robert,

I saw your tweet re: IE rounding errors.  I hadn't capitalized the "lastUnit" class name in the AG test grids. Oops.

Thanks for the link to this article.  I resolved the problem for better browsers (IE7+, FF, Safari, Chrome) by having no set width on the last unit in any row.  This means that the last unit absorbs the subtle rounding differences between those browsers.  overflow:hidden is the trick, if you read the spec it is a subtle effect of this property when no height is specified.

On the other hand, IE6.  :)  My grids used to have gutters.  I recently removed them, because I felt it was important that gutters live on content objects rather than grids. I used the gutter to help IE6 by floating the last unit right.  That meant that between the last two units an ~10px gap absorbed the rounding errors in IE6.  Ultimately, I need a way to tell IE6 that the last unit should be all the rest of the space on the line, whatever that might be.  Removing the width causes the calculation to be content dependent and, like you've talked about above, having a width causes (at some resolution or another) the unit to wrap.  

I really don't want to put gutters back in the grids (though they worked very well and were well tested with gutters)... so I'm searching for a solution. I've documented the bug here:
http://stubbornella.lighthouseapp.com/projects/26663-object-oriented-css/tickets/1-arnaud-gueras-test-wrapping-on-ie#ticket-1-4

Thanks again for your feedback,
Nicole</description>
		<content:encoded><![CDATA[<p>Hi Robert,</p>
<p>I saw your tweet re: IE rounding errors.  I hadn&#8217;t capitalized the &#8220;lastUnit&#8221; class name in the AG test grids. Oops.</p>
<p>Thanks for the link to this article.  I resolved the problem for better browsers (IE7+, FF, Safari, Chrome) by having no set width on the last unit in any row.  This means that the last unit absorbs the subtle rounding differences between those browsers.  overflow:hidden is the trick, if you read the spec it is a subtle effect of this property when no height is specified.</p>
<p>On the other hand, IE6.  <img src='http://agilewebmasters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  My grids used to have gutters.  I recently removed them, because I felt it was important that gutters live on content objects rather than grids. I used the gutter to help IE6 by floating the last unit right.  That meant that between the last two units an ~10px gap absorbed the rounding errors in IE6.  Ultimately, I need a way to tell IE6 that the last unit should be all the rest of the space on the line, whatever that might be.  Removing the width causes the calculation to be content dependent and, like you&#8217;ve talked about above, having a width causes (at some resolution or another) the unit to wrap.  </p>
<p>I really don&#8217;t want to put gutters back in the grids (though they worked very well and were well tested with gutters)&#8230; so I&#8217;m searching for a solution. I&#8217;ve documented the bug here:<br />
<a href="http://stubbornella.lighthouseapp.com/projects/26663-object-oriented-css/tickets/1-arnaud-gueras-test-wrapping-on-ie#ticket-1-4" rel="nofollow">http://stubbornella.lighthouseapp.com/projects/26663-object-oriented-css/tickets/1-arnaud-gueras-test-wrapping-on-ie#ticket-1-4</a></p>
<p>Thanks again for your feedback,<br />
Nicole</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Gentel</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8712</link>
		<dc:creator>Robert Gentel</dc:creator>
		<pubDate>Tue, 24 Feb 2009 20:46:29 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8712</guid>
		<description>Funny you should mention that, I was discussing its merits seriously with the lead developer last night. Ultimately, it has its own downsides that we find unacceptable (e.g. IE table rendering speed).</description>
		<content:encoded><![CDATA[<p>Funny you should mention that, I was discussing its merits seriously with the lead developer last night. Ultimately, it has its own downsides that we find unacceptable (e.g. IE table rendering speed).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: François Beausoleil</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8696</link>
		<dc:creator>François Beausoleil</dc:creator>
		<pubDate>Tue, 24 Feb 2009 14:27:02 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8696</guid>
		<description>This is tongue in cheek, but why not use a layout table ;)</description>
		<content:encoded><![CDATA[<p>This is tongue in cheek, but why not use a layout table <img src='http://agilewebmasters.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Gentel</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8605</link>
		<dc:creator>Robert Gentel</dc:creator>
		<pubDate>Mon, 23 Feb 2009 06:43:04 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8605</guid>
		<description>The requirements include liquid layout, which precludes such static positioning. Any of the CSS frameworks I mentioned would work out-of-box if there were not the liquid requirements. However this is a popular site with enough users at 800X600 to make a move to a 960 grid unacceptable, and enough users at high resolutions to make the "lowest common denominator" approach unacceptable.</description>
		<content:encoded><![CDATA[<p>The requirements include liquid layout, which precludes such static positioning. Any of the CSS frameworks I mentioned would work out-of-box if there were not the liquid requirements. However this is a popular site with enough users at 800X600 to make a move to a 960 grid unacceptable, and enough users at high resolutions to make the &#8220;lowest common denominator&#8221; approach unacceptable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chuck</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8604</link>
		<dc:creator>chuck</dc:creator>
		<pubDate>Mon, 23 Feb 2009 06:40:47 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8604</guid>
		<description>Oh, hey, you wrote back! Sorry I missed it; I was out and then typed the next one without refreshing.

Cool enough; whatever gets the job done for you! I'm a JS junkie myself. I was indeed quite surprised to see that resizing video with the rounded-up widths; I knew I didn't like using CSS width percentages as a production-ready layout solution, but I didn't know I had that much reason to stay away. Ouch!

Kick ass post, by the way, thanks. :)</description>
		<content:encoded><![CDATA[<p>Oh, hey, you wrote back! Sorry I missed it; I was out and then typed the next one without refreshing.</p>
<p>Cool enough; whatever gets the job done for you! I&#8217;m a JS junkie myself. I was indeed quite surprised to see that resizing video with the rounded-up widths; I knew I didn&#8217;t like using CSS width percentages as a production-ready layout solution, but I didn&#8217;t know I had that much reason to stay away. Ouch!</p>
<p>Kick ass post, by the way, thanks. <img src='http://agilewebmasters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chuck</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8602</link>
		<dc:creator>chuck</dc:creator>
		<pubDate>Mon, 23 Feb 2009 06:37:39 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8602</guid>
		<description>Sorry for the comment spam, but one more thing.... I love this stuff.... sorry :-P

I forgot to mention that taking the absolute positioning approach and calculating pixel coordinates and widths dynamically will actually produce a layout that is actually more precise than making divs that are sized according to a percentage of the width.

If the first column ends up wanting to be at 110.2 px from the left edge, stick it at 110; if the second one wants to be at 462.8px, stick it at 463... if the third column then wants to be at 815.4, and you naturally put it at 815px from the left, then the distance from the left edge of the first column horizontally to the second column (353px) is different than the distance from second to third (352px).

This means that the layout is actually more accurate than ever could have achieved using percentages, woot! Some nicer, newer browsers may do this rounding for you (maybe Firefox 3?), but I really don't know, because I never need to care, since I can make sure it happens all the time anyway. And yeah, if you want, you can make it degrade to best-effort CSS when JS is unavailable...

And don't worry about it being slow, either; if you write decent JS code, you can get something like a column layout done in negligible time, say, well under 1ms worth of execution. Take the MobileMe Gallery grid layout as an example; it'll manually lay out 100+ photos (each with width, height, left, and top) in under 10ms in Safari, and under 50ms in Firefox. Though IE is horrendously slow in other ways, the actual photo layout loop even works pretty well in IE when resizing the window with the album list on the left collapsed. I ramble too much... my point all along in is that laying out a few columns with absolutely calculated pixel coordinates would never be a hit in any browser or on any machine.

So... may as well go for the manually implemented "anti-aliasing" !! :-D</description>
		<content:encoded><![CDATA[<p>Sorry for the comment spam, but one more thing&#8230;. I love this stuff&#8230;. sorry <img src='http://agilewebmasters.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<p>I forgot to mention that taking the absolute positioning approach and calculating pixel coordinates and widths dynamically will actually produce a layout that is actually more precise than making divs that are sized according to a percentage of the width.</p>
<p>If the first column ends up wanting to be at 110.2 px from the left edge, stick it at 110; if the second one wants to be at 462.8px, stick it at 463&#8230; if the third column then wants to be at 815.4, and you naturally put it at 815px from the left, then the distance from the left edge of the first column horizontally to the second column (353px) is different than the distance from second to third (352px).</p>
<p>This means that the layout is actually more accurate than ever could have achieved using percentages, woot! Some nicer, newer browsers may do this rounding for you (maybe Firefox 3?), but I really don&#8217;t know, because I never need to care, since I can make sure it happens all the time anyway. And yeah, if you want, you can make it degrade to best-effort CSS when JS is unavailable&#8230;</p>
<p>And don&#8217;t worry about it being slow, either; if you write decent JS code, you can get something like a column layout done in negligible time, say, well under 1ms worth of execution. Take the MobileMe Gallery grid layout as an example; it&#8217;ll manually lay out 100+ photos (each with width, height, left, and top) in under 10ms in Safari, and under 50ms in Firefox. Though IE is horrendously slow in other ways, the actual photo layout loop even works pretty well in IE when resizing the window with the album list on the left collapsed. I ramble too much&#8230; my point all along in is that laying out a few columns with absolutely calculated pixel coordinates would never be a hit in any browser or on any machine.</p>
<p>So&#8230; may as well go for the manually implemented &#8220;anti-aliasing&#8221; !! <img src='http://agilewebmasters.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Gentel</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8601</link>
		<dc:creator>Robert Gentel</dc:creator>
		<pubDate>Mon, 23 Feb 2009 06:23:58 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8601</guid>
		<description>I want to note that the problem isn't specifically the jumping during resizing. In those examples, if the user's viewport is a particular width the layout would break without any resizing. But yes, JavaScript is one way to address this, but it has some downsides that render it unacceptable for this project.</description>
		<content:encoded><![CDATA[<p>I want to note that the problem isn&#8217;t specifically the jumping during resizing. In those examples, if the user&#8217;s viewport is a particular width the layout would break without any resizing. But yes, JavaScript is one way to address this, but it has some downsides that render it unacceptable for this project.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chuck</title>
		<link>http://agilewebmasters.com/robert/percentage-rounding-and-sub-pixel-perfection/#comment-8600</link>
		<dc:creator>chuck</dc:creator>
		<pubDate>Mon, 23 Feb 2009 06:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://agilewebmasters.com/?p=244#comment-8600</guid>
		<description>You know, with JavaScript, it's dog-easy to do this. Granted, certain browsers don't run JS (and redraw) continually during window resizes (Firefox is one), but the ease, control, and peace of mind that comes from manually calculating the positions of your boxes is totally worth it. Plus, if you're feeling anal about having the window resize action in Firefox actually render properly at every point during the resize, you could temporarily revert to the CSS-only approach, avoiding rounding error and overflow as you describe above. (My test I use for whether the user "is resizing" or not is whether an onresize has fired in the last 3/10 of a second; it seems to work pretty durned well.) Even IE renders during resize. Don't know about 8, but 6 and 7 do. Safari is close to flawless at it.

Absolute positioning is epic!

If you're wanting to make it REALLY perfect, then you can do only what a crazy person does, and put one-pixel COLUMNS on the left- and right-hand sides of each column box. Make sure you do all your JavaScript-based width divisions without doing a Math.floor or .ceil or .round anywhere to round to an integer (i.e. keep the decimal.) Make the DIVs the exact same color as the background of the column div, and set their opacity to the decimal fraction that is left over after rounding the position down or up to the nearest integer. That way, the outsides of the boxes themselves are actually rendered down to subpixel precision, and the world is a happier place for it! (Granted, the contents of the DIV columns will still nonetheless be jumping pixel by pixel, but while the page is in motion during a window resize, everything will be beautiful!)

JavaScript forever.!</description>
		<content:encoded><![CDATA[<p>You know, with JavaScript, it&#8217;s dog-easy to do this. Granted, certain browsers don&#8217;t run JS (and redraw) continually during window resizes (Firefox is one), but the ease, control, and peace of mind that comes from manually calculating the positions of your boxes is totally worth it. Plus, if you&#8217;re feeling anal about having the window resize action in Firefox actually render properly at every point during the resize, you could temporarily revert to the CSS-only approach, avoiding rounding error and overflow as you describe above. (My test I use for whether the user &#8220;is resizing&#8221; or not is whether an onresize has fired in the last 3/10 of a second; it seems to work pretty durned well.) Even IE renders during resize. Don&#8217;t know about 8, but 6 and 7 do. Safari is close to flawless at it.</p>
<p>Absolute positioning is epic!</p>
<p>If you&#8217;re wanting to make it REALLY perfect, then you can do only what a crazy person does, and put one-pixel COLUMNS on the left- and right-hand sides of each column box. Make sure you do all your JavaScript-based width divisions without doing a Math.floor or .ceil or .round anywhere to round to an integer (i.e. keep the decimal.) Make the DIVs the exact same color as the background of the column div, and set their opacity to the decimal fraction that is left over after rounding the position down or up to the nearest integer. That way, the outsides of the boxes themselves are actually rendered down to subpixel precision, and the world is a happier place for it! (Granted, the contents of the DIV columns will still nonetheless be jumping pixel by pixel, but while the page is in motion during a window resize, everything will be beautiful!)</p>
<p>JavaScript forever.!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
