<?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>GirlieMac! Blog &#187; Sandbox</title>
	<atom:link href="http://girliemac.com/blog/category/dev/sandbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://girliemac.com/blog</link>
	<description>Mac, iPhone, Safari and beyond</description>
	<lastBuildDate>Thu, 08 Jul 2010 05:57:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simulating MacOS Dock-like menu with CSS3</title>
		<link>http://girliemac.com/blog/2010/06/02/simulating-macos-dock-like-menu-with-css3/</link>
		<comments>http://girliemac.com/blog/2010/06/02/simulating-macos-dock-like-menu-with-css3/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 06:14:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/?p=173</guid>
		<description><![CDATA[

Since my original &#8220;CSS Aqua button&#8221; written last year, I have seen more and more fan CSS3 UI mimic of MacOS components around! I think I have seen some Mac docks too, but as I remember they all use jQuery.
So I was thinking about making one only with CSS.

Initially I thought it was easy &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://girliemac.com/blog/wp-content/images/dock-screenshot.jpg" alt="css3 Dock screenshot"/></p>
<p>
Since my original &#8220;CSS Aqua button&#8221; written last year, I have seen more and more fan CSS3 UI mimic of MacOS components around! I think I have seen some Mac docks too, but as I remember they all use jQuery.<br />
So I was thinking about making one only with CSS.
</p>
<p>Initially I thought it was easy &#8211; let&#8217;s make an hovered icon larger like 200%, and make siblings in 150% of the original size using CSS sibling selector, and done! A piece of cake, huh? &#8211; Then I realized I made a mistake. The adjacent-sibling selector apply to an element which is immediately <em>after</em> the element in markup, not both before and after.<br />
Oh well, so I needed to write a minimal JavaScript (so you don&#8217;t need to import a whole JS library) to add a class name to the element comes before the hovered object.</p>
<p>Anyway, here&#8217;s the <a href="http://girliemac.com/sandbox/dock.html" target="_blank">live-demo!</a> (Try it with the the latest Webkit Nightly or Safari 4) for the best experience!), and I&#8217;ll show you how I did-
</p>
<h3>Markup (Simplified)</h3>
<p>Let&#8217;s create menu items as a list.</p>
<pre class="html">
<code>
&lt;div id="dock-container"&gt;
  &lt;div id="dock"&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="http://android.com"&gt;&lt;img src="images/dock-icons/android.png"/>&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://palm.com"&gt;&lt;img src="images/dock-icons/palm.png"/&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;...
  &lt;/ul&gt;
  &lt;div class="base"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code>
</pre>
<p>The list should be displayed horizontally by setting the style to <code>#dock li {display:inline-block}</code>. Please see the source code from the demo for the details.
</p>
<h3>Magnify the icon with CSS transform</h3>
<p>
<img style="border:1px solid #666;" src="http://girliemac.com/blog/wp-content/images/dock-tutorial.png" align="right"/>First, let&#8217;s define the dock icon animation with css transition.<br />
The origin of the transform has to set to bottom, so the icon doesn&#8217;t scale from the middle of the icon. (Diagram #1).</p>
<p>I used only a webkit extension for this example but you can use <code>-moz</code> and <code>-o</code> extensions, for Firefox and Opera respectively.</p>
<p>Then, set the hover state &#8211; use css transform to scale the icon image up to 200%. Also you need to add some margin otherwise the enlarged icon overlaps with neighboring icons!
</p>
<pre class="css">
<code>
#dock li img {
  width: 64px;
  height: 64px;
  -webkit-box-reflect: below 2px
		    -webkit-gradient(linear, left top, left bottom, from(transparent),
		    color-stop(0.7, transparent), to(rgba(255,255,255,.5))); /* reflection is supported by webkit only */
  -webkit-transition: all 0.3s;
  -webkit-transform-origin: 50% 100%;
}
#dock li:hover img {
  -webkit-transform: scale(2);
  margin: 0 2em;
}
</code>
</pre>
<h3>Magnify adjacent icons</h3>
<pre class="css">
<code>
#dock li:hover + li img,
#dock li.prev img {
  -webkit-transform: scale(1.5);
  margin: 0 1.5em;
}
</code>
</pre>
<p>To magnify the icon at the right hand side of the hovered icon (Diagram #2), all you need to do is define the scale with using a CSS adjacent-sibling selector, E + F (an F element immediately preceded by an E element).</p>
<p>For the icon at the left (Diagram #3), ss I mentioned earlier, there is no css to get the <em>previous</em> sibling, so I need to rely on JavaScript.<br />
I used the DOM node interface, <code>previousElementSibling</code> to access the sibling node. <code>previousElementSibling</code> should be supported by Webkit, Opera and Firefox.</p>
<p>Basically what I am doing here is that get the mouseovered object (should be an img element), find the parent li element (the immediate parent should be an a-alement, not a li, so get a&#8217;s parent! Check the HTML code again!), find the previous sibling li, then give a classname &#8220;prev&#8221; so I can apply the style.<br />
Don&#8217;t forget to remove the class name as mouseout, otherwise the icon stays large.
</p>
<pre class="js">
<code>
function addPrevClass (e) {
  var target = e.target;
    if(target.getAttribute('src')) { // check if it is img
      var li = target.parentNode.parentNode;
      var prevLi = li.previousElementSibling;
      if(prevLi) {
        prevLi.className = 'prev';
      }

      target.addEventListener('mouseout', function() {
        prevLi.removeAttribute('class');
      }, false);
  }
}
if (window.addEventListener) {
  document.getElementById("dock").addEventListener('mouseover', addPrevClass, false);
}
</code>
</pre>
<p>For more details with the fancy CSS3 effects (e.g. the gradient and 3D-transform to create the &#8220;base&#8221; of the dock), please see the source code of the <a href="http://girliemac.com/sandbox/dock.html" target="_blank">demo page!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2010/06/02/simulating-macos-dock-like-menu-with-css3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS3 Box-Shadow with Inset Values &#8211; The Aqua Button ReReVisited!</title>
		<link>http://girliemac.com/blog/2010/02/04/css3-box-shadow-with-inset-values-the-aqua-button-rerevisited/</link>
		<comments>http://girliemac.com/blog/2010/02/04/css3-box-shadow-with-inset-values-the-aqua-button-rerevisited/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 05:22:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/?p=151</guid>
		<description><![CDATA[
This is my third article on CSS3 No Image Aqua Buttons. The previous articles include:

CSS3 Gradients: No Image Aqua Button
CSS3 Aqua Button – Revisited for Firefox 3.6
And this one &#8211; Read on!

Since Smashing Magazine has selected the original Aqua button demo for their article, &#8220;50 Brilliant CSS3/JavaScript Coding Techniques&#8221;, I have had so much more [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://girliemac.com/sandbox/button.html"><img alt="Screenshot ot CSS Aqua buttons" src="http://girliemac.com/blog/wp-content/images/screenshot_css3button_2.png" title="Screenshot" width="224" height="135" align="right" /></a></p>
<p>This is my third article on CSS3 No Image Aqua Buttons. The previous articles include:</p>
<ol>
<li><a href="http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/" target="_blank">CSS3 Gradients: No Image Aqua Button</a></li>
<li><a href="http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/" target="_blank">CSS3 Aqua Button – Revisited for Firefox 3.6</a></li>
<li>And this one &#8211; Read on!</li>
</ol>
<p>Since Smashing Magazine has selected the original Aqua button demo for their article, <a href="http://www.smashingmagazine.com/2010/02/01/50-brilliant-css3-javascript-coding-techniques/" target="_blank">&#8220;50 Brilliant CSS3/JavaScript Coding Techniques&#8221;</a>, I have had so much more visitors to my blog. </p>
<p>This resulted quality developers leave useful comments and tips for me &#8211; thank you, <a href="http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/#comment-1411" target="_blank">Zoley</a> for suggesting using <code>box-shadow</code> with the <em>inset</em> value, and a big thank you to <a href="http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/#comment-1428" target="_blank">Jim</a> for actually re-writing the Aqua button with the technique!!!</p>
<p>So, now the CSS3 Aqua button is revised with semantic markup (no more &#8220;glare&#8221; div! Yes, I complained it by myself before!) and shorter CSS.<br />
And this time, no CSS gradients! &#8211; use CSS <code>box-shadow</code> property with multiple <em>inset</em> values to draw layers of inner-shadows to create the visual effect.</p>
<h3>Syntax</h3>
<p><code>(-moz-)box-shadow:  none | &lt;shadow&gt; [,&lt;shadow&gt;]*    where &lt;shadow&gt; is defined as:  inset? &#038;&#038; [ &lt;offset-x&gt; &lt;offset-y&gt; &lt;blur-radius&gt;? &lt;spread-radius&gt;? &#038;&#038; &lt;color&gt;? ]<br />
</code></p>
<h3>Values</h3>
<p>from <a href="https://developer.mozilla.org/en/CSS/-moz-box-shadow" target="_blank">Mozilla Developer Center</a>:</p>
<blockquote><p>
<strong>inset (optional)</strong><br />
If not specified (default), the shadow is assumed to be a drop shadow (as if the box were raised above the content).<br />
The presence of the <code>inset</code> keyword changes the shadow to one inside the frame (as if the content was depressed inside the box). Inset shadows are drawn above background, but below border and content.<br/><br />
<strong>&lt;color&gt; (optional)</strong><br />
If not specified, the color depends on the browser. In Gecko (Firefox), the value of the <code>color</code> property is used. Safari&#8217;s shadow is transparent and therefore useless if &lt;color&gt; is omitted.<br/><br />
<strong>&lt;offset-x&gt; &lt;offset-y&gt; (required)</strong><br />
This are two &lt;length&gt; values to set the shadow offset. &lt;offset-x&gt; specifies the horizontal distance. Negative values place the shadow to the left of the element. &lt;offset-y&gt; specifies the vertical distance. Negative values place the shadow above the element.<br />
If both values are 0, the shadow is placed behind the element (and may generate a blur effect if &lt;blur-radius&gt; and/or &lt;spread-radius&gt; is set).<br/><br />
<strong>&lt;blur-radius&gt; (optional)</strong><br />
This is a third &lt;length&gt; value. The higher this value, the bigger the blur, so the shadow becomes bigger and lighter. If not specified, it will be 0.<br/><br />
<strong>&lt;spread-radius&gt; (optional)</strong><br />
This is a fourth &lt;length&gt; value. Positive values will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink. If not specified, it will be 0 (the shadow will be the same size as the element).<br />
<strong></strong><br/>
</p></blockquote>
<p>Note &#8211; The <code>box-shadow</code> property has been removed from <a href="http://www.w3.org/TR/css3-background/#the-box-shadow" target="_blank">W3C CSS3 Background</a> Candidate recommendation document.</p>
<h3>The Entire Code!</h3>
<p>Use <code>-moz</code> and <code>-webkit</code> prefix for <code>box-shodow</code> to support these browsers. For Opera, there&#8217;s no need to add <code>-o</code>.</p>
<p>Also, notice there are three <code>inset</code> values are defined for detailed visual effects!</p>
<pre class="html">
<code>
&lt;input type="button" class="new-aqua" value="Login"/&gt;
</code>
</pre>
<pre class="css">
<code>
input[type=button].new-aqua {
  width: 155px;
  height: 35px;
  background: #cde;
  border: 2px solid #ccc;
  border-color: #8ba2c1 #5890bf #4f93ca #768fa5;
  font: 600 16px/1 Lucida Sans, Verdana, sans-serif;
  color: #fff;
  text-shadow: rgba(10, 10, 10, 0.5) 1px 2px 2px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  border-radius: 16px; -moz-border-radius: 16px; -webkit-border-radius: 16px;
  box-shadow: 0 10px 16px rgba(66, 140, 240, 0.5), inset 0 -8px 12px 0 #6bf, inset 0 -8px 0 8px #48c, inset 0 -35px 15px -10px #7ad;
  -moz-box-shadow: 0 10px 16px rgba(66, 140, 240, 0.5), inset 0 -8px 12px 0 #6bf, inset 0 -8px 0 8px #48c, inset 0 -35px 15px -10px #7ad;
  -webkit-box-shadow: 0 10px 16px rgba(66, 140, 240, 0.5), inset 0 -8px 12px 0 #6bf, inset 0 -8px 0 8px #48c, inset 0 -35px 15px -10px #7ad;
}
.new-aqua:hover {
  text-shadow: rgb(255, 255, 255) 0px 0px 5px;
}
</code>
</pre>
<p><br/></p>
<p>View the <a href="http://girliemac.com/sandbox/button.html" target="_blank">live demo page</a>! This new aqua button works on FF 3.6, Webkit 4 (the current Safari 4 doesn&#8217;t support inset box-shadow yet), Chrome 4 and Opera 10. (But fails on 10.1 on Mac).</p>
<p style="color:#777"><em>* Edited on Feb.5 &#8211; Opera 10.1 fail and Safari4 (I noticed this works only on Webkit Nightly after published this!)</em></p>
<p>And again, a huge thanks to <a href="www.coroflot.com/trickitty" target="_blank">Jim Green</a> for the revised CSS!</p>
<h3>References</h3>
<ul style="margin-top:1em">
<li><a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html" target="_blank">Safari CSS Reference</a> by Apple Safari Dev Center</li>
<li><a href="https://developer.mozilla.org/en/CSS/-moz-box-shadow" target="_blank">-moz-box-shadow</a> by Mozilla Developer Center</li>
<li><a href="http://dev.opera.com/articles/view/css3-border-background-boxshadow/" target="_blank">CSS3 borders, backgrounds and box-shadows</a> by Dev.Opera</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2010/02/04/css3-box-shadow-with-inset-values-the-aqua-button-rerevisited/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>CSS3 Aqua Button &#8211; Revisited for Firefox 3.6</title>
		<link>http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/</link>
		<comments>http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 21:17:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Sandbox]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/?p=129</guid>
		<description><![CDATA[This is an update for the Aqua button tutorial. This update will add a support for Firefox 3.6. If you haven&#8217;t seen the article, please go read it before proceeding here.



On the end of November last year, Mozilla Hacks announced the support for CSS gradient in a background on upcoming Firefox 3.6 (which final version [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update for the <a href="http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/">Aqua button tutorial</a>. This update will add a support for Firefox 3.6. If you haven&#8217;t seen the article, please go read it before proceeding here.</p>
<p><br/></p>
<p>
<a href="http://girliemac.com/sandbox/button.html"><img alt="Screenshot ot CSS Aqua buttons" src="http://girliemac.com/blog/wp-content/images/screenshot_css3button_new.png" title="Screenshot" width="224" height="135" align="right" /></a></p>
<p>On the end of November last year, <a href="http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/" target="_blank">Mozilla Hacks announced</a> the support for CSS gradient in a background on upcoming Firefox 3.6 (which final version has just released recently). </p>
<p>As already been supported on WebKit, FF does support both linear and radial gradient, however, Mozilla has implemented differently &#8211;<br />
Most noticeably, Mozilla separate linear and radial gradient as <code>-moz-linear-gradient</code> and <code>-moz-radial-gradient</code>, while on WebKit, the syntax goes <code>-webkit-gradient</code> and you specify linear or radial.</p>
<p>Also the specification of each value is different too.<br />
If you want a linear gradient starting from red on top to ending at bottom in white, you need to define &#8211; </p>
<p>WebKit:<br />
<code>background: -webkit-gradient(linear, left top, right bottom, from(red), to(white)))</code><br />
Firefox:<br />
<code>background: -moz-linear-gradient(top, red, white);<br />
</code>
</p>
<h3>The Aqua Button Redefined</h3>
<p>Let&#8217;s re-create the aqua button, by adding <code>-moz</code> prefixed gradient definitions:</p>
<p>The button:</p>
<pre class="css">
<code>
.aqua{
  background-color: rgba(60, 132, 198, 0.8);
  border-top-color: #8ba2c1;
  border-right-color: #5890bf;
  border-bottom-color: #4f93ca;
  border-left-color: #768fa5;
  -webkit-box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px;
  -moz-box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px;
  background-image: -webkit-gradient(linear, 0% 0%, 0% 90%, from(rgba(28, 91, 155, 0.8)), to(rgba(108, 191, 255, .9)));
/* for FF 3.6 */
  background-image: -moz-linear-gradient(rgba(28, 91, 155, 0.8) 0%, rgba(108, 191, 255, .9) 90%);
}
</code>
</pre>
<p>and the glare:</p>
<pre class="css">
<code>
.button .glare {
  position: absolute;
  top: 0;
  left: 5px;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  height: 1px;
  width: 142px;
  padding: 8px 0;
  background-color: rgba(255, 255, 255, 0.25);
  background-image: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.7)), to(rgba(255, 255, 255, 0)));
  /* for FF 3.6 */
  background-image: -moz-linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 95%);
}
</code>
</pre>
<p>This is <a href="http://girliemac.com/sandbox/button.html" target="_blank">the actual html page</a>. Open it on Firefox 3.6 and see!</p>
<h3>More Info on Mozilla CSS Gradients</h3>
<ul style="margin-top:1em">
<li><a href="http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/" target="_blank">CSS gradients in Firefox 3.6</a> by HACKS.MOZILLA.ORG</li>
<li><a href="https://developer.mozilla.org/index.php?title=en/CSS/-moz-linear-gradient" target="_blank">-moz-linear-gradient</a> by Mozilla Developer Center</li>
<li><a href="https://developer.mozilla.org/index.php?title=en/CSS/-moz-radial-gradient" target="_blank">-moz-radial-gradient</a> by Mozilla Developer Center</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Webkit CSS 3D + Local DB Demo</title>
		<link>http://girliemac.com/blog/2009/09/03/webkit-css-3d-local-db-demo/</link>
		<comments>http://girliemac.com/blog/2009/09/03/webkit-css-3d-local-db-demo/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 06:37:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/09/03/webkit-css-3d-local-db-demo/</guid>
		<description><![CDATA[
Ever since I heard of Snow Loepard&#8217;s hardware-accelerated CSS, I wanted try some cool CSS animation for Safari 4.
So after installing Snow Leopard, I spent about a day and half to try creating my first 3D animation with Flickr API.
Honestly, I wasn&#8217;t sure where to get started to make some cool 3D effect, so what [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://girliemac.com/blog/wp-content/images/css3d.jpg" alt="css 3D screenshot"/></p>
<p>Ever since I heard of Snow Loepard&#8217;s hardware-accelerated CSS, I wanted try some cool CSS animation for Safari 4.</p>
<p>So after installing Snow Leopard, I spent about a day and half to try creating my first 3D animation with Flickr API.<br />
Honestly, I wasn&#8217;t sure where to get started to make some cool 3D effect, so what I did was I tried to reproduce the one on webkit.org example and modify a lot by trial and error approach.<br />
Also, I have been freqently asked about how I did with &#8220;My Favorites&#8221; feature on <a href="http://girliemac.com/blog/2009/08/29/pretty-cute-suite-another-cute-app-for-pre-from-me/">my Palm Pre app</a> (which is also a WebKit-based), so I throw the HTML5&#8217;s local storage demo with this 3D demo.
</p>
<p>So here, you can try my <a href="http://girliemac.com/sandbox/flickr_3d.html" target="_blank">CSS 3D and Local DB Demo</a>!!!<br />
Be sure to view this demo on Safari 4, iPhone Safari, or WebKit Nightly! This doesn;t seem to work on other Webkit-based browsers such as Chrome and Palm.
</p>
<p>I am not going to write a whole tutorial how to replicate this animation but I try to explain some examples.</p>
<h3>Spin a Wheel!</h3>
<p>Look at one of the flicke photo wheel on my demo. This is a combination of a few different animation.<br />
Let&#8217;s focus on the small wheel inside. This is the snippet of HTML of the wheel:</p>
<pre class="html">
<code>

&lt;div id="gallery"&gt;
  &lt;div id="pic01"&gt;&lt;img src="..."/&gt;&lt;/div&gt;
  &lt;div id="pic02"&gt;&lt;img src="..."/&gt;&lt;/div&gt;
  ... (10 more imgs)
&lt;/div&gt;	

</code>
</pre>
<p><img src="http://girliemac.com/blog/wp-content/images/coordinate.png" alt="3D Cood" align="left"/><br />
OK, for now, let&#8217;s ignore how each photo is rendered to form a loop, and just focus on the animation of one div, #gallery (= a wheel). A band of photos is ratating clockwise around Y-axis.<br />
This means the animation starts as <code>-webkit-transform: rotateY(0);</code> and goes around an circle for a whole 360 degree. <code> -webkit-transform: rotateY(-360deg);</code>.<br />
Use positive if you want to rotate in opposite direction.<br />
I set the whole circle completion span as 60 seconds in linier motion and the animation goes infinite. </p>
<p>This diagram from <a href="http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Transforms/Transforms.html" target="_blank">Apple&#8217;s Safari Reference Library</a> explains coordinates.</p>
<p>So the css for this movement is defined as:</p>
<pre class="css">
<code>
#gallery {
  -webkit-transform-style: preserve-3d;
  -webkit-animation: spinY 60s linear infinite;
}
</code>
</pre>
<pre class="css">
<code>
@-webkit-keyframes spinY {
  from { -webkit-transform: rotateY(0);}
  to   { -webkit-transform: rotateY(-360deg);}
}
</code>
</pre>
<p>Use 3D style, <code>-webkit-transform-style: preserve-3d;</code>to give 3D illusion. I set the initial perspective in its parent div as <code>-webkit-perspective: 380;</code>.<br />
It gives you an illusion of the depth. You can make the value lower to make it look more up-close to you.<br />
The unit of perspective should be &#8220;px&#8221;, but it looks like you&#8217;d better remove it for iPhone.</p>
<p><img src="http://girliemac.com/blog/wp-content/images/css3d_pers200.png" alt="perspective 200"/> <img src="http://girliemac.com/blog/wp-content/images/css3d_pers400.png" alt="perspective 400"/><br />
<img src="http://girliemac.com/blog/wp-content/images/css3d_pers500.png" alt="perspective 500"/> <img src="http://girliemac.com/blog/wp-content/images/css3d_pers0.png" alt="perspective 0"/></p>
<p>To figure out how to render each photo in loop, also other animations, please look at the source code of my demo.</p>
<p>Also, I will write about how to use HTML 5&#8217;s local storage sometimes later!</p>
<h3>References</h3>
<ul>
<li><a href="http://webkit.org/blog/386/3d-transforms/" target="_blank">3D Transforms</a> by Webkit.org</li>
<li><a href="http://webkit.org/blog/130/css-transforms/" target="_blank">CSS Transforms (2D)</a> by Webkit.org</li>
<li><a href="http://webkit.org/blog/138/css-animation/" target="_blank">CSS Animation</a> by Webkit.org</li>
<li><a href="http://www.w3.org/TR/css3-3d-transforms/" target="_blank">CSS 3D Transforms Module Level 3</a> W3C Working Draft</li>
<li><a href="http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Transforms/Transforms.html" target="_blank">Safari Reference Library -Transforms</a> by Apple</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/09/03/webkit-css-3d-local-db-demo/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Find Your Tweeting Neighbor on iPhone with GeoLocation</title>
		<link>http://girliemac.com/blog/2009/06/21/find-your-tweeting-neighbor-on-iphone-with-geolocation/</link>
		<comments>http://girliemac.com/blog/2009/06/21/find-your-tweeting-neighbor-on-iphone-with-geolocation/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 02:20:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/06/21/find-your-tweeting-neighbor-on-iphone-with-geolocation/</guid>
		<description><![CDATA[
iPhone OS 3.0 is now available, and developers can take advantage of the newly introduced geolocation feature in Safari browser.
To try it out quickly, I used Twitter Search API again to create a tiny test app called, NeighborTweet, which enable you to find out who are tweeting in your neighborhood. Basically, what it does is [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://girliemac.com/blog/wp-content/images/neighbortweet.png" alt="screenshot"/></p>
<p>iPhone OS 3.0 is now available, and developers can take advantage of the newly introduced <strong>geolocation</strong> feature in Safari browser.</p>
<p>To try it out quickly, I used Twitter Search API again to create a tiny test app called, <a href="http://girliemac.com/geo" target="_blank"/>NeighborTweet</a>, which enable you to find out who are tweeting in your neighborhood. Basically, what it does is that obtain your location, and pass the latitude and longitude data to Twitter search and display the result tweets.</p>
<p>Try it out on your iPhone with:<br />
Short URL <a href="http://girliemac.com/geo" target="_blank"/>http://bit.ly/K0ZaE</a><br />
or<br />
<a href=http://qrcode.kaywa.com/img.php?s=8&#038;d=http%3A%2F%2Fgirliemac.com%2Fgeo">This QR Code</a> with scanning app like BeeTagg.</p>
<p>If you are interested in learning more on Twitter search API and geocode, please read <a href="http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search" target="_blank">Twitter Wiki</a>.</p>
<p>OK, now here&#8217;s the code.<br />
To find out your location with Geolocation class is simple &#8211; you just call <code>getCurrentPosition()</code> method. This initiates an asynchronous request to detect the user&#8217;s position.</p>
<pre class="js">
<code>
navigator.geolocation.getCurrentPosition(someFunction)
</code>
</pre>
<p>Get latitude and longitude, by using <code>coords</code> instance:</p>
<pre class="js">
<code>
latitude = position.coords.latitude;
longitude = position.coords.longitude;
</code>
</pre>
<p>Here&#8217;s an actual code I used to create the sample app:</p>
<pre class="js">
<code>
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    callback(position.coords.latitude, position.coords.longitude);
  });
} else {
  alert("Geolocation services are not supported by your browser.");
} 

function callback(lat,lon){
  // twitter search json-p callback
  var geocode = "&#038;geocode=" + lat + "%2C" + lon + "%2C1mi";
  var fullUrl = url + geocode;
  ...
}
var url = "http://search.twitter.com/search.json?callback=getTweets";

function getTweets (json) {
  // display json data
  ...
}
</code>
</pre>
<h3>References</h3>
<p>Geolocation References:</p>
<ul>
<li><a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/GettingGeographicalLocations/GettingGeographicalLocations.html" target="_blank">Safari Reference Library &#8211; Getting Geographic Locations</a> &#8211; Apple Developer Connection</li>
<li><a href="https://developer.mozilla.org/En/Using_geolocation" target="_blank">Using geolocation</a> &#8211; Mozilla Developer Center</li>
<li><a href="http://www.w3.org/TR/geolocation-API/" target="_blank">Geolocation API Specification</a> &#8211; W3C Working Draft</li>
</ul>
<p>More References:</p>
<ul>
<li><a href="http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search" target="_blank">Twitter Search API Wiki</a></li>
<li><a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/" target="_blank">Remote JSON &#8211; JSONP</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/06/21/find-your-tweeting-neighbor-on-iphone-with-geolocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TweetTrendDunno &#8211; Played with APIs</title>
		<link>http://girliemac.com/blog/2009/06/16/tweettrenddunno-played-with-apis/</link>
		<comments>http://girliemac.com/blog/2009/06/16/tweettrenddunno-played-with-apis/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 05:20:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[App]]></category>
		<category><![CDATA[GirlieMac! News]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/06/16/tweettrenddunno-played-with-apis/</guid>
		<description><![CDATA[
I had a plenty of time to stay home and play with code right now so I mashed Twitter trend API, mixed with some BOSS news and image search stuff I used before, also Microsoft&#8217;s new Bing search results to create some silly and handy web app called TweetTrendDunno.
Basically, this grabs Twitter &#8220;trending topic&#8221; terms, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://girliemac.com/blog/wp-content/images/tweettrend.png" alt="TweetTrendDunno screenshot" /><br />
I had a plenty of time to stay home and play with code right now so I mashed Twitter trend API, mixed with some BOSS news and image search stuff I used before, also Microsoft&#8217;s new Bing search results to create some silly and handy web app called <a href="http://girliemac.com/tweetNews/">TweetTrendDunno</a>.</p>
<p>Basically, this grabs Twitter &#8220;trending topic&#8221; terms, and as a user click on each term you want to know about, it displays news articles, images, and Bing results (usually summary from Wikipedia helps you to figure out what the term means in general).</p>
<p>If you are Twitter user and ever wonder what people are talking about, give <a href="http://girliemac.com/tweetNews/">TweetTrendDunno</a> a try!</p>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/06/16/tweettrenddunno-played-with-apis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matrix Animation with WebKit CSS3</title>
		<link>http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/</link>
		<comments>http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/#comments</comments>
		<pubDate>Mon, 04 May 2009 05:40:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/</guid>
		<description><![CDATA[
I tweaked the WebKit CSS3 Animation example I made last time to create this &#8220;Matrix&#8221; animation for fun.


This is the screen capture of the animation on Safari 4.

You can try
the actual HTML page and see it working on current WebKit Nightly build or Safari 4.

To display the Katakana characters, I used @font-face rule to embed [...]]]></description>
			<content:encoded><![CDATA[<p>
I tweaked <a href="http://girliemac.com/blog/2009/02/18/using-keyframes-webkit-css-animation-examples/">the WebKit CSS3 Animation example I made last time</a> to create this &#8220;Matrix&#8221; animation for fun.
</p>
<p>
This is the screen capture of the animation on Safari 4.<br />
<img src="http://girliemac.com/blog/wp-content/images/screenshot_css3matrix.png" alt="css3 animation screenshot"/></p>
<p>You can try<br />
<a href="http://girliemac.com/sandbox/matrix.html" target="_blank">the actual HTML page</a> and see it working on current WebKit Nightly build or Safari 4.
</p>
<p>To display the Katakana characters, I used <code>@font-face</code> rule to embed a Katakana dingbat-like font, rather than using an actual Japanese input.<br />
Although I wanted display the kanakana vertically with using <code>writing-mode: tb-rl</code>, which I believe has been proposed for CSS2, this is not supported on Webkit so I had to use <code>-webkit-transform</code> to rotate each div to 90 degree to display vertically.<br />
This way, each letter faces 90 deg angle too, but oh well, this Japanese letters are random, used only for visual purpose and don&#8217;t mean anything so I guess this doesn&#8217;t matter for now.
</p>
<p>Let&#8217;s take a look at some of the CSS3 code, I am showing only important parts so if you would like to view the entire code, just open up the htmlpage and use Webkit&#8217;s inspector!</p>
<h3>Embed A Katakana Font</h3>
<pre class="css">
<code>
@font-face {
  font-family: Katakana;
  src: url('MoonBeams-katakana_.TTF');
}

#matrix{
  font-family: Katakana; /* use the embedded font */
  position: absolute;
  ... (more styles here) ...
}
</code>
</pre>
<p>@font-face rule is not supported by older Safari including iPhone.<br />
On supported browsers, you should be able to use either TrueType (.ttf) or OpenType (.otf).
</p>
<h3>Define Animations</h3>
<pre class="css">
<code>
@-webkit-keyframes fade{
    0%   {opacity: 1;}
    100% {opacity: 0;}
}
@-webkit-keyframes fall{
   	from {top: -250px;}
	to 	{top: 300px;}
}
</code>
</pre>
<p>I used both <em>%</em> and <em>from/to</em> keywords. But with %, you can define in-between state.</p>
<h3>Rotate the Katakana Strings</h3>
<pre class="css">
<code>
#matrix div{
  position: absolute;
  top: 0;
  -webkit-transform-origin: 0%;
  -webkit-transform: rotate(90deg);
  ...
</code>
</pre>
<p>By setting <code>-webkit-transform-origin</code> as 0%, the div block rotates 90 degrees at the far left.<br />
If you don&#8217;t set this, by default, it rotates at center axis.</p>
<h3>&#8230;and Use the Defined Animations</h3>
<pre class="css">
<code>
#matrix div{
  ...
  -webkit-animation-name: fall, fade;
  -webkit-animation-iteration-count: infinite; /* use 0 to infinite */
  -webkit-animation-direction: normal; /* default is normal. use 'alternate' to reverse direction */
  -webkit-animation-timing-function: ease-out;
}
</code>
</pre>
<p>For more detailed info on <code>-webkit-animation</code> properties, read <a href="http://developer.apple.com/documentation/appleapplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/doc/uid/TP30001266-VisualEffects" target="_blank">Apple&#8217;s Developer Connection</a></p>
<p>Again, this example is currently working only on the latest WebKit and Safari 4 (not iPhone).<br />
Google Chrome does not support @font-face or animation. (<code>-webkit-transform:rotate...</code> works), and I assume it does not work on Android either.<br />
(And I have no intention to try on other WebKit-base browsers like S60).</p>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>CSS3 Gradients: No Image Aqua Button</title>
		<link>http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/</link>
		<comments>http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/#comments</comments>
		<pubDate>Fri, 01 May 2009 05:33:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[Yahoo!]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/</guid>
		<description><![CDATA[Note (Jan 28, 2010): I added a Firefox support to this tutorial. Please visit the &#8220;revisited&#8221; article too!
Boooo, Yahoo! just had the 3rd round of layoff within a little over a year period, and this time I was axed with several more fellow excellent engineers of Mobile team. So now I have free time to [...]]]></description>
			<content:encoded><![CDATA[<p style="color:red"><em>Note (Jan 28, 2010): I added a Firefox support to this tutorial. Please visit the <a href="http://girliemac.com/blog/2010/01/28/css3-aqua-button-revisited-for-firefox-3-6/">&#8220;revisited&#8221;</a> article too!</em></p>
<p>Boooo, Yahoo! just had the 3rd round of layoff within a little over a year period, and this time I was axed with several more fellow excellent engineers of Mobile team. So now I have free time to spend on more coding!<br />
My job function needed full focus on products and it prevented me to have experiments and testing as I wanted to, so I always spent my own time to do. Now I can do whatever I want to while I am still on payroll. Yes! I am still paid my regular salary for a while, thanks for the new regulation <img src='http://girliemac.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
</p>
<p>
<img src="http://girliemac.com/blog/wp-content/images/screenshot_css3button.png" alt="css3 button screenshot" align="right"/><br />
OK, enough blah about the stupid corporate stuff.<br />
Anyway, I played around with WebKit CSS3 gradient and created a useless but fun stuff &#8211; an Aqua button with no images!<br />
Back in the time when Mac OS X was first announced, there&#8217;re a plenty of web tutorials that describe how to create the sexy aqua button with Photoshop, and now I can show how to create one with CSS!
</p>
<p>
Here&#8217;s a screen capture of the rendered button. You can see <a href="http://girliemac.com/sandbox/button.html" target="_blank">the actual HTML page</a> too.
</p>
<p>OK, let&#8217;s take a look at the code:</p>
<pre class="html">
<code>
&lt;div class="button aqua"&gt;
  &lt;div class="glare"&gt;&lt;/div&gt;
  Button Label
&lt;/div&gt;
</code>
</pre>
<h3>Create a Button Base and Styling Label</h3>
<pre class="css">
<code>
.button{
  width: 120px;
  height: 24px;
  padding: 5px 16px 3px;
  -webkit-border-radius: 16px;
  -moz-border-radius: 16px;
  border: 2px solid #ccc;
  position: relative;

  /* Label */
  font-family: Lucida Sans, Helvetica, sans-serif;
  font-weight: 800;
  color: #fff;
  text-shadow: rgba(10, 10, 10, 0.5) 1px 2px 2px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
</code>
</pre>
<p>The first part to render a rounded-corner rectangle. Set the position as relative to place &#8220;glare&#8221; inside of the button later.<br />
The second part is for styling the label.<br />
Give text-shodow with alpha-transparency. (Believe or not, Chrome and Android do not support text-shadow!)
</p>
<h3>Button Color and Shadow</h3>
<pre class="css">
<code>
.aqua{
  background-color: rgba(60, 132, 198, 0.8);
  background-image: -webkit-gradient(linear, 0% 0%, 0% 90%, from(rgba(28, 91, 155, 0.8)), to(rgba(108, 191, 255, .9)));
  border-top-color: #8ba2c1;
  border-right-color: #5890bf;
  border-bottom-color: #4f93ca;
  border-left-color: #768fa5;
  -webkit-box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px;
  -moz-box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px; /* FF 3.5+ */
}
</code>
</pre>
<p>Now, specify the appearance of the button and shadow at bottom.<br />
Here. I use the <em>-webkit-gradient</em> to create a nice-looking aqua gradient.</p>
<p>Notice that I use <code>-webkit-gradient</code> as a <code>background-image</code>, although there&#8217;s no physical graphics are added there.<br />
You can use gradients in <code>background-image</code>, <code>border-image</code>, <code>list-style-image</code> and content property.<br />
On Firefox, this is ignored and you see only Background-color. </p>
<p>The syntax for linear gradient is as follows:<br/><br />
<code>-webkit-gradient(lenear, <em>left top</em>, <em>right bottom</em>, from(<em>start color/alpha</em>), to(<em>end color/alpha</em>))</code>
</p>
<p>In this example, starts with dark blue from straight top to bottom (no angle) at 95%, not all way down, to blended into lighter blue.
</p>
<p>Then, I specified color on each border (so the css looks pretty messy).</p>
<p>Finally, give a nice shadow at bottom, with <code>-webkit-box-shadow</code>.<br />
Firefox 3.5+ supports it too, so duplicate it with <code>-moz-box-shadow</code>.</p>
<p>Syntax is as:<br/><br />
<code>[color/alpha] [horizontal offset] [vertical offset] [blur radius] </code>
</p>
<h3>Give it shine</h3>
<pre class="css">
<code>
.button .glare {
  position: absolute;
  top: 0;
  left: 5px;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  height: 1px;
  width: 142px;
  padding: 8px 0;
  background-color: rgba(255, 255, 255, 0.25);
  background-image: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.7)), to(rgba(255, 255, 255, 0)));
}
</code>
</pre>
<p>The class <em>glare</em> renders the glossy look on the button.<br />
First, give absolute position to the parent container, <em>button</em> to give shine in the right position.
</p>
<p><;li<br />
Again, use <em>-webkit-gradient</em> to create the glossy look, by playing with alpha-transparency.<br />
Start with the white (alpha 0.7) and end with complete transparent (alpha 0).
</p>
<p>Honestly, I do not like to have this non-semantic empty div block to only get this visual effect.<br />
I need to figure a better way to do.</p>
<p>References:</p>
<ul>
<li><a href="http://devworld.apple.com/safari/library/documentation/AppleApplications/Reference/SafariCSSRef/Articles/Functions.html#//apple_ref/doc/uid/TP40007955-SW25" target="_blank">Safari Reference Library &#8211; CSS Property Functions</a> by Apple</li>
<li><a href="http://webkit.org/blog/175/introducing-css-gradients/" target="_blank">Surfin&#8217; Safari &#8211; Introducing CSS Gradients</a></li>
<li><a href="https://developer.mozilla.org/en/CSS_Reference/Mozilla_Extensions" target="_blank">Mozilla Extensions</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/04/30/css3-gradients-no-image-aqua-button/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>Using Keyframes &#8211; WebKit CSS Animation Examples</title>
		<link>http://girliemac.com/blog/2009/02/18/using-keyframes-webkit-css-animation-examples/</link>
		<comments>http://girliemac.com/blog/2009/02/18/using-keyframes-webkit-css-animation-examples/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 01:15:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/02/18/using-keyframes-webkit-css-animation-examples/</guid>
		<description><![CDATA[Now WebKit supports explicit CSS animations! After seeing the new animation examples posted on WebKit.org, I needed to test keyframes by myself.
So I have created a dumb-downed version of the fallen leaves seen on webkit.org blog, called &#8220;Let it Snow&#8221;.
Unlike the fallen leaves example, I stick strictly with CSS only (means zero JavaScript). Also I [...]]]></description>
			<content:encoded><![CDATA[<p>Now WebKit supports explicit CSS animations! After seeing the new animation examples posted on <a href="http://webkit.org/blog/324/css-animation-2/" target="_blank">WebKit.org</a>, I needed to test <code>keyframes</code> by myself.<br />
So I have created a dumb-downed version of the fallen leaves seen on webkit.org <a href="http://webkit.org/blog-files/leaves/index.html" target="_blank">blog</a>, called &#8220;Let it Snow&#8221;.</p>
<p>Unlike the fallen leaves example, I stick strictly with CSS only (means zero JavaScript). Also I tested on Webkit nightly and an iPhone (OS 2.0) Safari. On my iPhone (<code class="small">Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5G77 Safari/525.20</code>), the animation is slow and some feature is ingored. </p>
<p>Well, let&#8217;s see the &#8220;Let It Snow&#8221; animation <a href="http://girliemac.com/sandbox/snow.html" target="_blank">in action!</a></p>
<h3>How to use Keyframes?</h3>
<p>Keyframes are specified with the CSS &#8220;At-Rule&#8221; by using the keyword,<strong>@-webkit-keyframes</strong>, followed by an identifier (= <em>animation-name</em>)</p>
<pre class="css">
	<code>
@-webkit-keyframes <em>animation-name</em> {
 from {
   <em>style definition ["Before"-state]</em>
 }
 to {
   <em>style definition ["After"-state]</em>
 }
}
	</code>
</pre>
<p>A keyframe defines the styles applied within the animation. To specify multiple frames, use &#8220;%&#8221; instead of &#8220;from&#8221; and &#8220;to&#8221; keywords.<br />
Here&#8217;s an actual example I used for &#8220;Let it Snow&#8221;.</p>
<pre class="css">
	<code>
@-webkit-keyframes fade {
  0%   { opacity: 0; }
  10%  { opacity: 0.8; }
  100% { opacity: 0; }
}
	</code>
</pre>
<p>This style is applie to create each snow flake appearance. A snowflake blurry appears (increase opacity) when 10% of the time elapsed (The total time is defined later. I&#8217;ll explain it next).<br />
And at the end, the snowflake disappears (opacity back to zero).</p>
<p>Once the animation timeframe is defined, apply it using -webkit-animation-name and related properties.<br />
I set total animation duration as 5 seconds, and the animatin goes forever (= <em>infinite</em> times. The default is 1).<br />
See the simplified example below.</p>
<pre class="css">
	<code>
#snow div {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 5s;
  -webkit-animation-iteration-count: infinite;
}
	</code>
</pre>
<pre class="html">
	<code>
&lt;div id="snow" class="snow"&gt;
  &lt;div&gt;&amp;#10053;&lt;/div&gt; /* an entity for &#10053; */
&lt;/div&gt;
	</code>
</pre>
<h3>Using Transform</h3>
<p>Let&#8217;s rotate and move around snowflakes by using <code class="small">-webkit-transform</code>.<br />
<code class="small">rotate</code>, of course, rotate the element, and <code class="small">translate</code> specifies a 2D translation by the vector [tx, ty]. (For more explanations, please see <a href="http://webkit.org/specs/CSSVisualEffects/CSSTransforms.html" target="_blank">CSS transform spec</a> page).<br />
I used percent, 0 and 100% here, but of course you can use &#8220;from&#8221; and &#8220;to&#8221;.<br />
Also note that <code class="small">transform</code> doesn&#8217;t seem to work on current iPhone Safari yet.</p>
<pre class="css">
	<code>
@-webkit-keyframes spin{
  0%   { -webkit-transform: rotate(-180deg) translate(0px, 0px);}
  100% { -webkit-transform: rotate(180deg) translate(10px, 75px);}
}
	</code>
</pre>
<p>You can just add the amination-name to the #snow div selector, separating with comma.</p>
<pre class="css">
	<code>
#snow div {
  -webkit-animation-name: fade, spin;
  ...
}
	</code>
</pre>
<h3>More</h3>
<p>For the &#8220;Let it snow&#8221; example, I also include the cheesy &#8220;accumulate&#8221; keyframe to make snow accumulate on ground. Kinda ugly though.<br />
Moreover, I gave the <code class="small">-webkit-animation-duration</code> to individual snowflake so all flakes don&#8217;t fall all together! </p>
<pre class="css">
	<code>
.snowflake {
  color: #fff;
  font-size: 2em;
  position: absolute; (Note: The parent container is set relative positioned!)
}
.snowflake.f1 {
  left: 40px;
  -webkit-animation-duration: 5s;
}
.snowflake.f2 {
  font-size: 1.8em;
  left: 120px;
  -webkit-animation-duration: 7s;
}
...
	</code>
</pre>
<pre class="html">
	<code>
&lt;div id="snow" class="snow"&gt;
  &lt;div class="snowflake f1"&gt;&amp;#10053;&lt;/div&gt; /* an entity for &#10053; */
  &lt;div class="snowflake f2"&gt;&amp;#10052;&lt;/div&gt; /* an entity for &#10052; */
  ... <em>(add two more snowflake-div in the actual sample)</em>
&lt;/div&gt;
	</code>
</pre>
<p>To view the entire markup and CSS, just view source of the <a href="http://girliemac.com/sandbox/snow.html" target="_blank">sample file</a>!</p>
<p><br/></p>
<p>Resources:</p>
<ul>
<li><a href="http://webkit.org/blog/138/css-animation/" target="_blank">Surfin&#8217; Safari &#8211; CSS Animation</a></li>
<li><a href="http://webkit.org/blog/324/css-animation-2/" target="_blank">Surfin&#8217; Safari &#8211; CSS Animation 2</a></li>
<li><a href="http://webkit.org/specs/CSSVisualEffects/CSSAnimation.html" target="_blank">CSS Effects proposed specifications &#8211; Animation</a></li>
<li><a href="http://webkit.org/specs/CSSVisualEffects/CSSTransforms.html" target="_blank">CSS Effects proposed specifications &#8211;  Transforms</a></li>
<li><a href="http://developer.apple.com/documentation/appleapplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/doc/uid/TP30001266-VisualEffects" target="_blank">Safari Supported CSS Properties &#8211; &#8220;Visual Effects&#8221;</a></li>
<li><a href="https://developer.apple.com/webapps/docs/samplecode/CardFlip/" target="_blank">Apple Web Apps Reference Library &#8220;CardFlip&#8221;</a> (Registration required)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/02/18/using-keyframes-webkit-css-animation-examples/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>WebKit Comparison on CSS3</title>
		<link>http://girliemac.com/blog/2009/01/23/webkit-comparison-on-css3/</link>
		<comments>http://girliemac.com/blog/2009/01/23/webkit-comparison-on-css3/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 03:02:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://girliemac.com/blog/2009/01/23/webkit-comparison-on-css3/</guid>
		<description><![CDATA[Bitstream has launched a new mobile browser called Bolt, which is a J2ME browser and use WebKit as a rendering engine.
Instead of writing a review on this new WebKit browser, I decided to just do some quick CSS3 test on variety of WebKit browsers!
If you rather read the review, I recommend WAP Review. There&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>Bitstream has launched a new mobile browser called <a href="http://boltbrowser.com/" target="_blank">Bolt</a>, which is a J2ME browser and use WebKit as a rendering engine.</p>
<p>Instead of writing a review on this new WebKit browser, I decided to just do some quick CSS3 test on variety of WebKit browsers!<br />
If you rather read the review, I recommend <a href="http://wapreview.com/blog/?p=2598" target="_blank">WAP Review</a>. There&#8217;s a very detailed great article on Bolt there.</p>
<h3>WebKit browsers I used</h3>
<ol>
<li>WebKit Nightly for Mac OS X (as a Control)<br/><code class="small">Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/528.11+ (KHTML, like Gecko) Version/4.0dp1 Safari/526.11.2</code></li>
<li>iPhone Safari<br/><code class="small">Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5G77 Safari/525.20</code></li>
<li>Chrome by Google<br/><code class="small">Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.43 Safari/525.19</code></li>
<li>HTC Dream Android<br/><code class="small">Mozilla/5.0 (Linux; U; Android 1.0; en-us; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2</code>
<li>Nokia N95 8GB<br/><code class="small">Mozilla/5.0 (SymbianOS/9.2 U; Series60/3.1 NokiaN95_8GB/10.0.021; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413</code></li>
<li>Bolt 0.74 on Nokia N95 8GB<br/><code class="small">Mozilla/5.0 (X11; 78; CentOS; US-en) AppleWebKit/527+ (KHTML, like Gecko) Bolt/0.741 Version/3.0 Safari/523.15</code></li>
</ol>
<h3>CSS3 Styling I tested</h3>
<pre class="css">
<code>
.opracity {opacity: .5;}
.textShadow {text-shadow: #777 2px 2px 2px;}
.textShadows2 {text-shadow: rgba(0,0,255, .7) 3px 3px 2px, rgba(255,0,0, .7) -3px -3px 2px;
.ellipsis{text-overflow: ellipsis; width: 200px; overflow: hidden;}
.borderRadius {background-color: #666; color: #fff; width: 200px; padding: 10px; -webkit-border-radius: 10px;}
.boxShodow{-webkit-box-shadow: #000 3px 2px 6px; width: 200px; padding:5px;}
.strokeAndFill{-webkit-text-stroke: 1px green; -webkit-text-fill-color: #ccc; font-size: 2em; }
.borderImg{-webkit-border-image: url(button.gif) 0 13 0 13 stretch stretch; border-width: 0px 13px; padding: 5px 0 7px;}
</code>
</pre>
<h3>Results</h3>
<div id="screenshot">
<p>	<strong>WebKit Nightly</strong> &#8211; This is how everything should look like.<br />
	<img src="http://girliemac.com/blog/wp-content/images/css3/mac_webkit.png" alt="WebKit Nightly"/><br />
	<br/><br />
	<strong>iPhone Safari</strong><br />
	<img src="http://girliemac.com/blog/wp-content/images/css3/iphone.png" alt="iPhone"/><br />
	<br/><br />
	<strong>Chrome</strong> and <strong>Android Browser</strong><br />
	<img src="http://girliemac.com/blog/wp-content/images/css3/chrome.png" alt="Chrome"/><img src="http://girliemac.com/blog/wp-content/images/css3/android.png" alt="Android"/><br />
	<br/><br />
	<strong>Nokia &#8220;Web&#8221;</strong> and <strong>Bolt</strong> on N95 8GB<br />
	<img src="http://girliemac.com/blog/wp-content/images/css3/nokiaN95_webkit.png" alt="Nokia"/>  &nbsp; <img src="http://girliemac.com/blog/wp-content/images/css3/nokiaN95_bolt.png" alt="Bolt"/><br />
<small>* note: Android&#8217;s actual screen res is 320&#215;480. The screenshot is not an actual size. (Obviously this is a photograph!). Also the screenshot for iPhone is from emulator but I tested on an actual device as well.</small>
</div>
<h3>Summary</h3>
<table summary="CSS3 Support Chart on various WebKit browsers" class="chart">
<tr>
<th>Properties</th>
<th>WebKit Ntly</th>
<th>iPhone</th>
<th>Chrome</th>
<th>Android</th>
<th>Nokia</th>
<th>Bolt</th>
</tr>
<tr>
<td>opacity</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N</td>
<td class="n">N</td>
</tr>
<tr>
<td>text-shodow</td>
<td class="y">Y</td>
<td class="p">Y*</td>
<td class="n">N</td>
<td class="n">N</td>
<td class="n">N</td>
<td class="n">N</td>
</tr>
<tr>
<td>text-overflow (ellipsis)</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N**</td>
</tr>
<tr>
<td>border-radius</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N</td>
<td class="n">N</td>
</tr>
<tr>
<td>-webkit-box-shodow</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N</td>
<td class="n">N**</td>
</tr>
<tr>
<td>-webkit-text-stroke</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N</td>
<td class="n">N</td>
<td class="n">N</td>
<td class="n">N</td>
</tr>
<tr>
<td>-webkit-text-fill</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N</td>
<td class="y">Y</td>
</tr>
<tr>
<td>-webkit-border-image</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="y">Y</td>
<td class="n">N</td>
<td class="y">Y</td>
</tr>
</table>
<p><small>* Basic feature is spported, but not multiple shodows.<br/>** Not degraded gracefully. Contents become unreadable so should be avoided.</small></p>
<h3>Additional Notes</h3>
<p>Besides the CSS3 test, it is noticeable that Bolt does not honer css font size, weight and header with H tag. This is happening to another J2ME browser, Opera Mini 4 (not tested here since Opera Mini is not WebKit-based). Additionally, like Opera Mini, Bolt uses proxy for rendering and compression. Data is passed through proxy before sending to device.</p>
]]></content:encoded>
			<wfw:commentRss>http://girliemac.com/blog/2009/01/23/webkit-comparison-on-css3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
