<?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>samuli.hakoniemi.net &#187; css3</title>
	<atom:link href="http://samuli.hakoniemi.net/tag/css3/feed/" rel="self" type="application/rss+xml" />
	<link>http://samuli.hakoniemi.net</link>
	<description></description>
	<lastBuildDate>Thu, 20 Oct 2011 10:03:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<atom:link rel='hub' href='http://samuli.hakoniemi.net/?pushpress=hub'/>
		<item>
		<title>Having Fun With CSS Animations</title>
		<link>http://samuli.hakoniemi.net/having-fun-with-css-keyframes/</link>
		<comments>http://samuli.hakoniemi.net/having-fun-with-css-keyframes/#comments</comments>
		<pubDate>Wed, 25 May 2011 19:23:03 +0000</pubDate>
		<dc:creator>Samuli Hakoniemi</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[animations]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[keyframes]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://samuli.hakoniemi.net/?p=710</guid>
		<description><![CDATA[<a href="/having-fun-with-css-keyframes"><img src="/wp-content/images/css-keyframes/title-css3-keyframes.png" alt="Having Fun With CSS3 Keyframes" /></a>
More than two years ago CSS Animations were represented in WebKit. Up until now, they've been supported only in Safari and Chrome.

In this article we will go through what it takes to create keyframe animations. I'll create a simple demonstration of an icon character which comes alive with a little help of animation.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsamuli.hakoniemi.net%2Fhaving-fun-with-css-keyframes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsamuli.hakoniemi.net%2Fhaving-fun-with-css-keyframes%2F&amp;source=zvona&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="/wp-content/images/css-keyframes/title-css3-keyframes.png" alt="Having Fun With CSS3 Keyframes" /></p>
<div class='ingress'>
<p>More than two years ago CSS Animations were represented in WebKit. Up until now, they&#8217;ve been supported only in Safari and Chrome.</p>
<p>Recently I noticed, when upgrading to Android 3.1 that it dramatically enhanced the performance of CSS Animations and Transitions. And only few days ago, Firefox 5 Beta was released which has decent support for keyframes, and also better performance for transitions. Therefore I decided to write a brief article about CSS Animations and using keyframes.</p>
<p>In this article we will go through what it takes to create keyframe animations. I&#8217;ll create a simple demonstration of an icon character which comes alive with a little help of keyframes.</p>
</div>
<h2>Foreword</h2>
<p>[tweetmeme]</p>
<p>This article won&#8217;t help with the basics and all the details of CSS Keyframes. If you&#8217;re unfamiliar with keyframes, I strongly suggest reading Smashing Magazine&#8217;s article <a rel="external" href="http://www.smashingmagazine.com/2011/05/17/an-introduction-to-css3-keyframe-animations/" title="An Introduction To CSS3 Keyframe Animations">&#8220;An Introduction To CSS3 Keyframe Animations&#8221;</a>.</p>
<p>If you&#8217;re also unfamiliar with CSS Transitions, you can also read my article <a href="/css3-transitions-are-we-there-yet/" title="CSS3 Transitions – Are We There Yet?">&#8220;CSS3 Transitions – Are We There Yet?&#8221;</a>.</p>
<p>It&#8217;s good to notice that there already exists tools for creating proper CSS Animations, like <a rel="external" href="http://animatable.com/" title="Animatable">Animatable</a> that are worth of checking. Especially, if you&#8217;re not that much of a fan writing endless keyframes rules and css declarations</p>
<h2>Browser Support</h2>
<p>I&#8217;ve tested this example with recent builds of Google Chrome, Firefox 5 Beta, iPhone 4 / iPad and Android 3.1 with Browser (Chrome) and Firefox Beta. So, if you&#8217;re viewing this article with any of those, then you&#8217;re good to go.</p>
<p>There are indications that also Opera will support CSS Animations in near future. Let&#8217;s see when that will be. However, Internet Explorer won&#8217;t be supporting CSS Animations &#8211; they&#8217;re not even supporting CSS Transitions yet.</p>
<h2>The Icon</h2>
<p>In this example we&#8217;ll build an icon with separate head, body and background. We&#8217;ll add some movement with keyframes to each object while trying to achieve as realistic result as possible without too much of an effort.</p>
<p>The character icon in demonstration is from <a rel="external" href="http://www.mikamobile.com/game3_1.html" title="Battleheart">Battleheart</a>, developed by Mika Mobile.</p>
<h2>The Head</h2>
<p><img src="/wp-content/images/css-keyframes/wiz-head.png" alt="Wizard's head" style="float:left;margin:0px 20px 10px 0px;" /> We start by defining the behavior of an animation for the head. This is done by defining a keyframes rule called &#8220;breathe-head&#8221;.</p>
<pre name="code" class="css">@-webkit-keyframes breathe-head {
    0% {
        -webkit-transform: rotate(1deg) translate3d(0px, 0px, 0px);
    }
    40% {
        -webkit-transform: rotate(-3deg) translate3d(-2px, -1px, 0px);
    }

    100% {
        -webkit-transform: rotate(1deg) translate3d(0px, 0px, 0px);
    }
}</pre>
<p><b>NOTE:</b> I&#8217;m using property called <i>translate3d</i> for moving the head slightly backwards. It&#8217;s good to understand that only transformable properties (+ opacity) can be animated with hardware acceleration. Translate3d(0,0,0) is good to have to ensure hardware acceleration of animations even if it&#8217;s not needed for any other use. I&#8217;ve even encountered many situations where animation performance hasn&#8217;t been smooth eg. on iOS Web Applications until (over)usage of translate3d().</p>
<h2>Twice the Fun!</h2>
<p>For some (unknown) reason, it isn&#8217;t possible to add -moz-keyframes rule at the same declaration, so we need to declare keyframes rules again:</p>
<pre name="code" class="css">@-moz-keyframes breathe-head {
    0% {
        -moz-transform: rotate(1deg) translate(0px, 0px);
    }
    40% {
        -moz-transform: rotate(-3deg) translate(-2px, -1px);
    }

    100% {
        -moz-transform: rotate(1deg) translate(0px, 0px);
    }
}</pre>
<p>I&#8217;m not using translate3d() since it seems Firefox only understands translate(). But it&#8217;s good enough for performance since it should be also hardware accelerated on Firefox.</p>
<h2>The Body</h2>
<p><img src="/wp-content/images/css-keyframes/wiz-body.png" alt="Wizard's body" style="float:left;margin:0px 20px 10px 0px;" /> Next, we&#8217;ll animate the body of the character. We don&#8217;t need any wildly bouncing animation since we&#8217;re operating with an (small) icon. Constant movement has to be subtle or otherwise it can start to irritate users:</p>
<pre name="code" class="css">@-webkit-keyframes breathe-body {
    0% {
        -webkit-transform: translate3d(0px,0px,0px);
    }

    40% {
        -webkit-transform: translate3d(0px,-3px,0px);
    }

    100% {
        -webkit-transform: translate3d(0px,0px,0px);
    }
}</pre>
<p>And the same rules needs to be applied for -moz-keyframes like we did with the head.</p>
<h2>The Background</h2>
<p><img src="/wp-content/images/css-keyframes/wiz-bg2.png" alt="Wizard's background" style="float:left;margin:0px 20px 10px 0px;" />I wanted to add something more to a movement and decided to draw a subtle background &#8220;sun&#8221; which keeps rotating behind the character:</p>
<pre name="code" class="css">@-webkit-keyframes rotate-bg {
    0% {
        -webkit-transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
    }
}</pre>
<p>Rotating background is very straight-forwarded; we rotate it once per timeline we&#8217;ll define later on.</p>
<h2>Keyframes are Done &#8211; What Next?</h2>
<p>Now that we&#8217;ve defined keyframe rules, we must take them into use:</p>
<pre name="code" class="css">.character {
    -webkit-animation: breathe-body 3000ms infinite both ease-in-out;
    -moz-animation: breathe-body 3000ms infinite both ease-in-out;
}

.character .head {
    -webkit-animation: breathe-head 3000ms infinite both ease-in-out;
    -moz-animation: breathe-head 3000ms infinite both ease-in-out;
}

.rotating {
    -webkit-animation: rotate-bg 30s infinite linear;
    -moz-animation: rotate-bg 30s infinite linear;
}</pre>
<p>I&#8217;m using short-hand declarations, and eg. for <b>.character .head</b> we declare: <i>&#8220;Use breathe-head keyframe rules in a three seconds long loop which last infinite time and is animated with in-out easing equation&#8221;</i>.</p>
<p>Value &#8220;both&#8221; stands for animation-fill-mode should define the status of first and last keyframe. But in my case I didn&#8217;t notice anything special when I trying other possible values &#8220;forwards&#8221; or &#8220;backwards&#8221; (this could be since both start and end keyframe has similar values).</p>
<h2>The End Result</h2>
<p>I needed to declare more CSS for getting things in correct place. But the example code above is practically the soul and heart of the animation. But here is the end result of an animated wizard icon:</p>
<style type="text/css">
@-webkit-keyframes breathe-head {
    0% {
        -webkit-transform: rotate(1deg) translate3d(0px, 0px, 0px);
    }
    40% {
        -webkit-transform: rotate(-3deg) translate3d(-2px, -1px, 0px);
    }
    100% {
        -webkit-transform: rotate(1deg) translate3d(0px, 0px, 0px);
    }
}
@-moz-keyframes breathe-head {
    0% {
        -moz-transform: rotate(1deg) translate(0px, 0px);
    }
    40% {
        -moz-transform: rotate(-3deg) translate(-2px, -1px);
    }
    100% {-moz-transform: rotate(1deg) translate(0px, 0px);}
}
@-webkit-keyframes breathe-body {
    0% {-webkit-transform: translate3d(0px,0px,0px);}
    40% {-webkit-transform: translate3d(0px,-3px,0px);}
    100% {-webkit-transform: translate3d(0px,0px,0px);}
}
@-moz-keyframes breathe-body {
    0% {
        -moz-transform: translate(0px,0px);
    }
    40% {
        -moz-transform: translate(0px,-3px);
    }
    100% {
        -moz-transform: translate(0px,0px);
    }
}
@-webkit-keyframes rotate-bg {
    0% {
        -webkit-transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
    }
}
@-moz-keyframes rotate-bg {
    0% {-moz-transform: rotate(0deg);}
    100% {-moz-transform: rotate(360deg);}
}
.icon {
    position:relative;
    overflow:hidden;
    z-index:2;
    left:250px;
    top:50px;
    margin:-48px 0px 0px -48px;
    width:96px;
    height:96px;
    border:5px solid #988033;
    background-color:#D0C080;
    -webkit-border-radius:6px;
    -webkit-box-shadow:0px 0px 10px rgba(96,64,32, 0.5);
    -webkit-transform:translate3d(0px,0px,0px);
    -moz-border-radius:6px;
    -moz-box-shadow:0px 0px 10px rgba(96,64,32, 0.5);
    -moz-transform:translate3d(0px,0px,0px);
}
.bg {
    position:absolute;
    left:-48px;
    top:-48px;
    width:192px;
    height:192px;
}
.rotating {
    background:url(/wp-content/images/css-keyframes/wiz-bg.png) center center no-repeat #D0C080;
    -webkit-animation: rotate-bg 30s infinite linear;
    -moz-animation: rotate-bg 30s infinite linear;
}
.character .head {
    width:58px;
    height:75px;
    -webkit-animation: breathe-head 3000ms infinite both ease-in-out;
    -moz-animation: breathe-head 3000ms infinite both ease-in-out;
}
.character {
    width:80px;
    height:96px;
    position:absolute;
    z-index:1;
    left:8px;top:16px;-webkit-animation: breathe-body 3000ms infinite both ease-in-out;-moz-animation: breathe-body 3000ms infinite both ease-in-out;
}
.wizard {background:url(/wp-content/images/css-keyframes/wiz-body.png) center center no-repeat;}
.wizard .head {background:url(/wp-content/images/css-keyframes/wiz-head.png) center center no-repeat;}
</style>
<div class="icon">
<div class="bg rotating"></div>
<div class="character wizard">
<div class="head"></div>
</div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>How do you like it? It&#8217;s my first animation ever :).</p>
]]></content:encoded>
			<wfw:commentRss>http://samuli.hakoniemi.net/having-fun-with-css-keyframes/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>CSS3 Transitions &#8211; Are We There Yet?</title>
		<link>http://samuli.hakoniemi.net/css3-transitions-are-we-there-yet/</link>
		<comments>http://samuli.hakoniemi.net/css3-transitions-are-we-there-yet/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 21:05:51 +0000</pubDate>
		<dc:creator>Samuli Hakoniemi</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[transitions]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://samuli.hakoniemi.net/?p=261</guid>
		<description><![CDATA[<a href="http://samuli.hakoniemi.net/css3-transitions-are-we-there-yet"><img class="img_main" src="/wp-content/images/css3-transitions/css3-transitions-are-we-the.jpg" alt="CSS3 Transitions - Are We There Yet?" /></a>

Cascading Style Sheets 3 has been available for "some time" (first time introduced nine years ago). However, CSS3 hasn't been available in common use for more than two years.

CSS3 Transitions in real use were introduced in late 2007 by Safari. At that time, they were referred as "CSS Animations", but the terminology changed when Safari introduced their proprietary features also called "CSS Animations".


I've split the topic in two articles. In this first article I'll make a generic overview on CSS3 Transitions. Additionally, I'll introduce some of the basic implementations and evaluate few CSS properties, meant for creating transformations and transitions

This article also contains references to excellent CSS3 articles. So after reading this article, go ahead and upgrade your knowledge about CSS3 Transitions with them.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsamuli.hakoniemi.net%2Fcss3-transitions-are-we-there-yet%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsamuli.hakoniemi.net%2Fcss3-transitions-are-we-there-yet%2F&amp;source=zvona&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<link rel="stylesheet" href="/wp-content/customCSS/css3-transitions-are-we.css" />
<p><img class="img_main" src="/wp-content/images/css3-transitions/css3-transitions-are-we-the.jpg" alt="CSS3 Transitions - Are We There Yet?" /></p>
<div class="ingress">Cascading Style Sheets 3 has been available for &#8220;some time&#8221; (<a href="http://www.w3.org/TR/css3-roadmap/" title="Introduction to CSS3">first time introduced nine years ago</a>). However, CSS3 hasn&#8217;t been available in common use for more than two years.</p>
<p>CSS3 Transitions in real use were <a href="http://webkit.org/blog/138/css-animation/" title="CSS Animation">introduced in late 2007</a> by Safari. At that time, they were referred as &#8220;CSS Animations&#8221;, but the terminology changed when Safari introduced their proprietary features also called <a href="http://webkit.org/blog/324/css-animation-2/" title="CSS Animations">CSS Animations</a></p>
<p>I&#8217;ve split this topic in two articles. In this first article I&#8217;ll make a generic overview on CSS3 Transitions. Additionally, I&#8217;ll introduce some of the basic implementations and evaluate few CSS properties, meant for creating transformations and transitions.</p>
<p>This article also contains references to excellent CSS3 articles. So after reading this article, go ahead and upgrade your knowledge about CSS3 Transitions with them.</p></div>
<p>[tweetmeme]</p>
<p>This article is also published in Finnish, titled as <a href="http://gfx.fi/2010/04/css3-transitiot-olemmeko-jo-perilla/" title="CSS3 Transitiot - olemmeko jo perillä?">&#8220;CSS3 Transitiot &#8211; olemmeko jo perillä?&#8221;</a> at <a rel="external" href="http://gfx.fi" title="gfx.fi">gfx.fi</a>.</p>
<p>Like mentioned above, the whole topic has been split in two parts. The first part is offering a general overview in current status of CSS3 Transitions. Second part is called <b>&#8220;CSS3 Transitions &#8211; Problems and Solutions&#8221;</b>, which will explain in details how CSS3 Transitions behave in different browsers.</p>
<p>The first part of the article contains following sections:</p>
<ul>
<li><a href="#gettingStarted">Getting Started</a> &#8211; what you must have on your workstation</li>
<li><a href="#theBasicsOfTheBasics">The Basics of the Basics</a> &#8211; what you should know about transitions</li>
<li><a href="#theBasics">The Basics</a> &#8211; what you must know about CSS3 Transitions <b>(demo section)</b></li>
<li><a href="#conclusions">Conclusions</a> &#8211; are we there yet?</li>
<li><a href="#resources">External Resources</a> &#8211; places where you must visit after reading this article</li>
</ul>
<p><img class="img_sub" src="/wp-content/images/css3-transitions/getting-started.jpg" alt="Getting Started" /></p>
<h2 id="gettingStarted">Getting Started</h2>
<p>To get started, you&#8217;ll need a browser that supports CSS3 Transitions:</p>
<ul>
<li><a href="http://www.apple.com/safari/download/" title="Apple Safari Download">Apple Safari</a> (supported in Safari 3.1 and later, and in iPhone OS 2.0 and later.)</li>
<li><a href="http://www.google.com/chrome/" title="Google Chrome Download">Google Chrome</a></li>
<li><a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/" title="Mozilla Firefox 3.7 a">Mozilla Firefox 3.7 alpha</a> (also known as Minefield)</li>
<li><a href="http://www.opera.com/browser/" title="Opera 10.5x">Opera 10.5x</a> (also supported by Opera Mobile 10 beta 2)</li>
</ul>
<h3>What about Internet Explorer?</h3>
<p>At the moment it&#8217;s announced that Internet Explorer 9 isn&#8217;t going to support CSS3 Transitions. The best support for IE Transitions and Transformations can be achieved with <a href="http://msdn.microsoft.com/en-us/library/ms533014(v=VS.85).aspx">Matrix Filter</a>.</p>
<p>Additionally, I recommend reading an article titled <a href="http://www.useragentman.com/blog/2010/04/05/cross-browser-animated-css-transforms-even-in-ie/" title="Cross-Browser Animated CSS Transforms — Even in IE">Cross-Browser Animated CSS Transforms — Even in IE</a>, written by <i>Zoltan “Du Lac” Hawryluk</i> who is the author of <a rel="external" href="http://www.useragentman.com/blog/csssandpaper-a-css3-javascript-library/" title="cssSandpaper – a CSS3 JavaScript Library">cssSandpaper</a>.</p>
<p><img class="img_sub" src="/wp-content/images/css3-transitions/the-basics-of-the-basics.jpg" alt="The Basics of the Basics" /></p>
<h2 id="theBasicsOfTheBasics">The Basics of the Basics</h2>
<p>Unfortunately, there&#8217;s no &#8220;one rule to rule them all&#8221; for transitions. Actually every browser has their own proprietary properties. Fortunately the syntax for values are consistent.</p>
<h3>What can be transitioned?</h3>
<p>Most properties can be transitioned and therefore I see no reason to list them here explicitly. However, there are some difference between browsers and the most obvious exception is that Firefox 3.7a doesn&#8217;t support transition of transformations at all.</p>
<h3>The property values for transitions</h3>
<p>Transitions have four values to declare at maximum:<br />
<b>Shorthand:</b></p>
<pre name="code" class="css">-webkit-transition: property_name duration timing_function delay;
-moz-transition: property_name duration timing_function delay;
-o-transition: property_name duration timing_function delay;
transition: property_name duration timing_function delay;</pre>
<p>You also can declare every value explicitly:</p>
<p><b>(Target) Property:</b></p>
<pre name="code" class="css">-webkit-transition-property: property_name;
-moz-transition-property: property_name;
-o-transition-property: property_name;
transition-property: property_name;</pre>
<p><b>Duration:</b></p>
<pre name="code" class="css">-webkit-transition-duration: duration;
-moz-transition-duration: duration;
-o-transition-duration: duration;
transition-duration: duration;</pre>
<p>Duration (like delay) can be entered either in seconds (eg. <i>0.5s</i>) or in milliseconds (eg. <i>500ms</i>). It&#8217;s important to note that if the value is entered without suffix, transition will not work at all.</p>
<p><b>Timing (of motion):</b></p>
<pre name="code" class="css">-webkit-transition-timing-function: timing_function;
-moz-transition-timing-function: timing_function;
-o-transition-timing-function: timing_function;
transition-timing-function: timing_function;</pre>
<p>Available timing functions:</p>
<ul>
<li><a rel="external" href="http://www.netzgesta.de/dev/cubic-bezier-timing-function.html" title="Cubic Bezier Timing Function">cubic-bezier(cp1<sub>x</sub>, cp1<sub>y</sub>, cp2<sub>x</sub>, cp2<sub>y</sub></a>)</li>
<li><i>ease</i> &#8211; equivalent to cubic-bezier(0.25, 0.1, 0.25, 1.0).</li>
<li><i>linear</i> &#8211; equivalent to cubic-bezier(0.0, 0.0, 1.0, 1.0).</li>
<li><i>ease-in</i> &#8211; equivalent to cubic-bezier(0.42, 0, 1.0, 1.0).</li>
<li><i>ease-out</i> &#8211; equivalent to cubic-bezier(0, 0, 0.58, 1.0).</li>
<li><i>ease-in-out</i> &#8211; equivalent to cubic-bezier(0.42, 0, 0.58, 1.0).</li>
</ul>
<p><b>Delay:</b></p>
<pre name="code" class="css">-webkit-transition-delay: delay;
-moz-transition-delay: delay;
-o-transition-delay: delay;
-transition-delay: delay;</pre>
<p>Delay (like duration) can be entered either in seconds (eg. <i>0.5s</i>) or in milliseconds (eg. <i>500ms</i>).</p>
<p>In general, it&#8217;s good to declare transitions on default state selectors without pseudo classes. This will cause transition played in both direction, eg. when hovering.</p>
<p>Remember, you have to enter all the properties four times before being cross-browser compliant. Therefore it&#8217;d be best to use shorthand codes for keeping your CSS code clean. </p>
<p><img class="img_sub" src="/wp-content/images/css3-transitions/the-basics.jpg" alt="The Basics" /></p>
<h2 id="theBasics">The Basics</h2>
<p>Now, I&#8217;m going to demonstrate some of the transitions. You must either hover or to click activation buttons for displaying transitions.</p>
<p>All the code examples below has no browser proprietary format written &#8211; this is for saving space.</p>
<h3>Basic Transition: Dimensions and Scaling</h3>
<p>I&#8217;ll start by demonstrating the basic transition. It also demonstrates the difference between width+height and scale transform.</p>
<pre name="code" class="css">#widthHeight	{transition:all 500ms;}
#widthHeight:hover	{width:200px;height:200px;line-height:200px;}

#scale	{transition:all 500ms;}
#scale:hover	{transform:scale(2.0, 2.0);}</pre>
<div class="block" id="widthHeight">Width + Height</div>
<div class="block" id="scale">Scale</div>
<div class="clear">&nbsp;</div>
<p>As you can see, width and height increases normally while scaling is treated almost like absolutely positioned element. On scaling, the transform-origin is set to middle while modifying width+height origin is on the top-left corner.</p>
<h3>Transition with Timing Function</h3>
<p>Below there are two blocks rotating; one with <em>linear</em> timing-function and second one with <em>ease</em>.</p>
<pre name="code" class="css">#rotateLinear	{position:relative;clear:both;left:0px;
		transition:all 2500ms linear;}

#rotateEasing	{position:relative;clear:both;left:0px;
		transition:all 2500ms ease;}

#rotateLinear:target	{left:200px;
			transform:rotate(360deg);}

#rotateEasing:target {left:200px;
			transform:rotate(360deg);}
</pre>
<div class="block" id="rotateLinear">Linear</div>
<div class="block" id="rotateEasing">Easing</div>
<div class="clear">&nbsp;</div>
<p><a class="target" href="#rotateLinear">Activate Linear</a><a class="target" href="#rotateEasing">Activate Easing</a></p>
<div class="clear">&nbsp;</div>
<p>As you probably noticed, the movement is different but both transitions ends at the same time (after 2500ms).</p>
<h3>Transition with Delay</h3>
<p>Delays are useful in some cases. And they&#8217;re very easy to implement in transitions:</p>
<pre name="code" class="css">#bgColorDelay	{background-color:#12142B;
		transition:background-color 500ms linear 800ms;}
#bgColorDelay:hover	{background-color:#336699;}</pre>
<div class="block" id="bgColorDelay">800ms delay</div>
<div class="clear">&nbsp;</div>
<h3>Transition Chaining</h3>
<p>Transitions can also be chained. This doesn&#8217;t come as a default feature, but chaining can be achieved by adding delay between transitions:</p>
<pre name="code" class="css">#widthHeightOpacity	{transition:width 500ms, height 500ms linear 500ms, opacity 500ms linear 1000ms;}
#widthHeightOpacity:hover	{width:200px;height:200px;opacity:0.1;}</pre>
<div class="block" id="widthHeightOpacity">w+h+opacity</div>
<div class="clear">&nbsp;</div>
<p>This has one caveat: transitions are displayed in same order no matter whether the element is hovered or it&#8217;s in default state. And that makes no sense. Therefore we need to reverse the declarations (compared to earlier examples) as following:</p>
<pre name="code" class="css">#widthHeightOpacity	{
	transition:width 500ms 1000ms, height 500ms linear 500ms, opacity 500ms linear;
}

#widthHeightOpacity:hover	{width:200px;height:200px;opacity:0.1;
	transition:width 500ms, height 500ms linear 500ms, opacity 500ms linear 1000ms;
}</pre>
<h3>Is There Anything Else?</h3>
<p>Well of course, there might be something else I haven&#8217;t noticed at this point. But what I&#8217;m trying to emphasize is that transitions are rather simple to implement (although they require a bit extra work for cross-browser compliancy).</p>
<p><img class="img_sub" src="/wp-content/images/css3-transitions/conclusions.jpg" alt="Conclusions" /></p>
<h2 id="conclusions">Conclusions</h2>
<p>Are we there yet? Yes, we&#8217;re over halfway there. Transitions in general are very cool in proper use.</p>
<p>However, I&#8217;m personally still bit skeptic with CSS3 Transitions: at this point, you can&#8217;t rely on them and you must do cross-browser testing thoroughly. I&#8217;ll cover some of the problems at the following part of this article series. And I&#8217;m also going to briefly compare CSS3 Transitions with jQuery Animations.</p>
<p>If you&#8217;re dealing with a platform solely running on WebKit (like iPhone or Adobe AIR) then go ahead and enjoy the full power of both CSS3 Transitions and WebKit animations.</p>
<p><img class="img_sub" src="/wp-content/images/css3-transitions/external-resources.jpg" alt="External Resources" /></p>
<h2 id="resources">External Resources</h2>
<p>Here are some good resources provided both by browser vendors and other external authors. I strongly suggest reading them for adopting transitions and other CSS3 techniques.</p>
<ul>
<li><a rel="external" href="http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Transitions/Transitions.html" title="Safari CSS Visual Effect Guide: Transitions">Safari CSS Visual Effect Guide: Transitions</a></li>
<li><a rel="external" href="https://developer.mozilla.org/en/CSS/CSS_transitions">Mozilla CSS transitions &#8211; MDC</a></li>
<li><a rel="external" href="http://www.opera.com/docs/specs/presto23/css/transitions/" title="Opera: CSS3 Transitions support in Opera Presto 2.3">Opera: CSS3 Transitions support in Opera Presto 2.3</a></li>
</ul>
<ul>
<li><a rel="external" href="http://www.css3.info/" title="CSS3.info">CSS3.info</a></li>
<li><a rel="external" href="http://www.css3please.com/" title="CSS3 Please">CSS3, Please! The Cross-Browser CSS3 Rule Generator</a></li>
<li><a rel="external" href="http://net.tutsplus.com/tutorials/html-css-techniques/css-fundametals-css-3-transitions/" title="CSS Fundamentals: CSS 3 Transitions | NetTuts+">CSS Fundamentals: CSS 3 Transitions | NetTuts+</a></li>
<li><a rel="external" href="http://www.webdesignerdepot.com/2010/01/css-transitions-101/" title="CSS Transitions 101 | Webdesigner Depot">CSS Transitions 101 | Webdesigner Depot</a></li>
<li><a rel="external" href="http://24ways.org/2009/going-nuts-with-css-transitions" title="Going Nuts with CSS Transitions | 24 ways">Going Nuts with CSS Transitions | 24 ways</a></li>
<li><a rel="external" href="http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Animations/Animations.html" title="Safari CSS Visual Effect Guide: Animations">Safari CSS Visual Effect Guide: Animations</a></li>
</ul>
<h2>Comments?</h2>
<p>Feel free to comment any part of the article. Additionally, if you know good resources about CSS3 Transitions, go ahead and contribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://samuli.hakoniemi.net/css3-transitions-are-we-there-yet/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Cross-browser Rotation Transformation with CSS</title>
		<link>http://samuli.hakoniemi.net/cross-browser-rotation-transformation-with-css/</link>
		<comments>http://samuli.hakoniemi.net/cross-browser-rotation-transformation-with-css/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 11:37:50 +0000</pubDate>
		<dc:creator>Samuli Hakoniemi</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[transformation]]></category>

		<guid isPermaLink="false">http://samuli.hakoniemi.net/?p=41</guid>
		<description><![CDATA[I was about not to publish anything before Christmas - just calming down, taking some extra time to get my blog design finished, plugins installed, and so on..

..but no. I got way too excited when I heard today that <a title="Opera Labs" href="http://labs.opera.com/news/2009/12/22/">Opera 10.5 pre-alpha for Labs</a> was released. In other words, this means that an updated version of Opera's layout engine, Presto, was out to play with - meaning, that CSS3 Transformations and Transitions are available also for Opera.

In this article, we write some lines of CSS and create rotating transform effect with all the common browsers, including Internet Explorer and the latest version of Opera.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsamuli.hakoniemi.net%2Fcross-browser-rotation-transformation-with-css%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsamuli.hakoniemi.net%2Fcross-browser-rotation-transformation-with-css%2F&amp;source=zvona&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>[tweetmeme]<br />
I was about not to publish anything before Christmas &#8211; just calming down, taking some extra time to get my blog design finished, plugins installed, and so on..</p>
<p>..but no. I got way too excited when I heard today that <a title="Opera Labs" href="http://labs.opera.com/news/2009/12/22/">Opera 10.5 pre-alpha for Labs</a> was released. In other words, this means that an updated version of Opera&#8217;s layout engine, Presto, was out to play with &#8211; meaning, that CSS3 Transformations and Transitions are available also for Opera.</p>
<p>In this article, we write some lines of CSS and create rotating transform effect with all the common browsers, including Internet Explorer and the latest version of Opera.</p>
<h2>Issues with Opera and IE</h2>
<p>Opera offers <a href="http://www.opera.com/docs/specs/presto23/css/transitions/">CSS3 Transitions support in Opera Presto 2.3</a>, at least partially. By the specification, we&#8217;re able to take advantage of <em>-o-transform:rotate(deg);</em>.</p>
<p>IE is a bit trickier (big surprise). Fortunately there&#8217;s a nice filter available, called <a href="http://msdn.microsoft.com/en-us/library/ms533014%28VS.85%29.aspx">Matrix</a>. The values for matrix are quite complicated, hence some assistance with Javascript is needed.</p>
<p>In my case, I&#8217;ve created some functionality and bound it with HTC file to CSS selectors. The functionality is based on values of property <em>-ms-transformation</em>. I&#8217;ve also implemented <em>-ms-transition</em> for transitions, but this will be examined further on later posts.</p>
<h2>Example code</h2>
<p>In this example, I&#8217;ll be using A-elements for hover support in IE6. I&#8217;ve already written a small implementation similar to <a href="http://www.xs4all.nl/~peterned/csshover.html">Whatever:hover</a>, but that &#8220;project&#8221; is still taking baby steps.</p>
<p>So let&#8217;s cut the chase and create some lines of code:</p>
<h3>HTML</h3>
<p><code>&lt;a href="#" id="one" class="rotate"&gt;This is 45deg -rotated element.&lt;/a&gt;<br />
&lt;a href="#" id="two" class="rotate"&gt;This is 10deg -rotated element, which rotates to 45deg when hovered.&lt;/a&gt;</code></p>
<h3>CSS</h3>
<p><code>#one	{<br />
behavior:url(-ms-transform.htc);<br />
-moz-transform:rotate(45deg);<br />
-webkit-transform:rotate(45deg);<br />
-o-transform:rotate(45deg);<br />
-ms-transform:rotate(45deg);<br />
}<br />
#two	{<br />
behavior:url(-ms-transform.htc);<br />
-moz-transform:rotate(10deg);<br />
-webkit-transform:rotate(10deg);<br />
-o-transform:rotate(10deg);<br />
-ms-transform:rotate(10deg);<br />
}<br />
#two:hover	{<br />
-moz-transform:rotate(45deg);<br />
-webkit-transform:rotate(45deg);<br />
-o-transform:rotate(45deg);<br />
-ms-transform:rotate(45deg);<br />
}</code></p>
<h2>Demo</h2>
<p>You can view demo at <a class="linkForDemo" href="http://demo.hakoniemi.net/Cross-browserRotateTransformationwithCSS/">Demo section: Cross-browser Rotation Transformation with CSS</a>.</p>
<h2>Final thoughts</h2>
<p>Although everything &#8220;is not fully there&#8221;, this article shows the possibility for implementing cross-browser CSS3 Transformations purely with CSS.</p>
<p>In addition, this post works as an opening post of my blog. Feel free to give feedback. Merry Christmas!</p>
]]></content:encoded>
			<wfw:commentRss>http://samuli.hakoniemi.net/cross-browser-rotation-transformation-with-css/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

