<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; Rory C-B</title>
	<atom:link href="http://devblog.blackberry.com/author/rcraigbarnes/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 08:21:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; Rory C-B</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Improper use of CSS background-size</title>
		<link>http://devblog.blackberry.com/2013/01/improper-use-of-css/</link>
		<comments>http://devblog.blackberry.com/2013/01/improper-use-of-css/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 16:39:23 +0000</pubDate>
		<dc:creator>Rory C-B</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[BlackBerry 10 browser]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[sample code]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=13252</guid>
		<description><![CDATA[Order and omissions matter when it comes to CSS. Until recently there was a quirk in the WebKit rendering engine related to the shorthand background property. The good news is that it has been fixed; the bad news is that it potentially breaks legacy code. If the background-size property is set prior to declaring background [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=13252&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Order and omissions matter when it comes to CSS. Until recently there was a quirk in the WebKit rendering engine related to the shorthand background property. The good news is that it has been fixed; the bad news is that it potentially breaks legacy code. If the background-size property is set prior to declaring background property it no longer behaves in the same fashion. The simplest solution is to declare the size of a background image in the background property.</p>
<p>code:</p>
<pre>a.icon.good2 {
	background: #215387 url(test-sprite@2x.png) 4px -6px / 40px 82px no-repeat;
	}</pre>
<p>Note: Including the size in the background property is not supported in older browsers. See example 2 below for a more backwards compatible solution.</p>
<p><span id="more-13252"></span></p>
<p><strong>Issue:</strong></p>
<p>The W3C spec for the background shorthand property specifies that when declared without a size property it initializes size to &#8216;background-size: auto auto;&#8217;. Previously there was quirk with WebKit where if size was omitted it just didn&#8217;t initialize the size property for the background. This allowed for a previously declared background-size declaration to remain intact, displaying the image at its proper size. This quirk has since been removed and the latest release of WebKit now follows the W3C spec.</p>
<p><i>Bad code</i></p>
<pre>a.icon {
	background-size: 40px 82px;
	}
a.icon.bad {
	background: #215387 url(test-sprite@2x.png) 4px -6px no-repeat;
	}</pre>
<p><i>Produces</i></p>
<p><img class="alignnone size-full wp-image-13253" alt="" src="http://rimdevblog.files.wordpress.com/2013/01/impropercss.jpg?w=127&#038;h=91" width="127" height="91" /></p>
<p><strong>Solution</strong></p>
<p>1. Add size to the background short-hand property and eliminate the background-size property</p>
<p><i>Code</i></p>
<pre>a.icon.good2 {
     background: #215387 url(test-sprite@2x.png) 4px -6px / 40px 82px no-repeat;
}</pre>
<p><i>Produces</i></p>
<p><img class="alignnone size-full wp-image-13254" alt="" src="http://rimdevblog.files.wordpress.com/2013/01/impropercsspic2.jpg?w=127&#038;h=91" width="127" height="91" /></p>
<p>2. If you must resize a background-image via a background-size property declare background size after the background property so it isn&#8217;t overridden.</p>
<p>Code</p>
<pre>a.icon.good {
	background: #215387 url(test-sprite@2x.png) 4px -6px no-repeat;
	}
a.icon.good {
	background-size: 40px 82px;
	}</pre>
<p>Produces</p>
<p><img class="alignnone size-full wp-image-13255" alt="" src="http://rimdevblog.files.wordpress.com/2013/01/impropercsspic3.png?w=127&#038;h=91" width="127" height="91" /></p>
<p><strong>References:</strong></p>
<p><a href="http://www.w3.org/TR/css3-background/#the-background" target="_new">http://www.w3.org/TR/css3-background/#the-background</a><br />
<a href="https://bugs.webkit.org/show_bug.cgi?id=97761" target="_new">https://bugs.webkit.org/show_bug.cgi?id=97761</a><br />
<a href="http://lists.w3.org/Archives/Public/www-style/2012Oct/0112.html" target="_new">http://lists.w3.org/Archives/Public/www-style/2012Oct/0112.html</a><br />
<a href="http://caniuse.com/#search=background-size" target="_new">http://caniuse.com/#search=background-size</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/13252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/13252/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=13252&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2013/01/improper-use-of-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/242389c732166964f7406def92b0a476?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rcraigbarnes</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2013/01/impropercss.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2013/01/impropercsspic2.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2013/01/impropercsspic3.png" medium="image" />
	</item>
	</channel>
</rss>
