<?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>theChrisWalker.net &#187; CSS</title>
	<atom:link href="http://thechriswalker.net/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://thechriswalker.net</link>
	<description>I like Web Development</description>
	<lastBuildDate>Tue, 31 Aug 2010 07:42:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>More WebKit Goodies &#8211; CSS Transforms and Transitions &#8211; the OSX Dock example</title>
		<link>http://thechriswalker.net/2009-03/more-webkit-goodies-css-transforms-and-transitions-the-osx-dock-example.html</link>
		<comments>http://thechriswalker.net/2009-03/more-webkit-goodies-css-transforms-and-transitions-the-osx-dock-example.html#comments</comments>
		<pubDate>Thu, 12 Mar 2009 19:44:22 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=98</guid>
		<description><![CDATA[As promised last time, I here we will discuss the transforms in WebKit, and how they can be used to create interactive applications without Javascript (for animation that is &#8211; we still need it for AJAX, etc.) Tranforms have been implemented on a few browser using proprietary syntax, and the same is true of WebKit. [...]]]></description>
			<content:encoded><![CDATA[<p>As promised last time, I here we will discuss the transforms in WebKit, and how they can be used to create interactive applications without Javascript (for animation that is &ndash; we still need it for AJAX, etc.)</p>
<p>Tranforms have been implemented on a few browser using proprietary syntax, and the same is true of WebKit. As we shall see further down the article though, the WebKit transitions make them so much more powerful.</p>
<p>But what are they? They modify an element, without displacing it&#8217;s original setting within the document, which means we can move it about and the spacing doesn&#8217;t change. </p>
<style type='text/css'>
.flip:hover { -webkit-transform:rotate(180deg); }
.transition { -webkit-transition:-webkit-transform 1s linear }
.transition-allover, .transition-left { -webkit-transform-origin:30% 50%;-webkit-transition:-webkit-transform 1s linear; }
.transition-left:hover {
 -webkit-transform:rotate(180deg);
 -webkit-transform-origin:30% 50%; 
}
.transition-allover:hover {
  -webkit-transform: rotate(180deg) scale(1.5) translate(-50%, 50%);
  -webkit-transform-origin:30% 50%; 
}
#hey-look-at-me:target pre {
  outline:2px solid red;
  color:#f0f;
}
#hey-look-at-me pre{
  -webkit-transition-property:outline, color;
  -webkit-transition-duration:500ms;
}
</style>
<blockquote style='color:#c00;'><p>Remember these will only work in WebKit based browsers, for example Safari for Mac, Chrome for Windows or Midori for Linux</p></blockquote>
<p>An example: how about rotation.</p>
<pre class='code flip'>element:hover {
  -webkit-transform:rotate(180deg);
}</pre>
<p>Not very exciting, but combine this with a transition! (Try putting you mouse in the middle of the box for best effect)</p>
<pre class='code flip transition'>element:hover {
  -webkit-transform:rotate(180deg);
}
element {
  -webkit-transition:-webkit-transform 1s linear
}</pre>
<p><span id="more-98"></span></p>
<p>Much more useful! But there&#8217;s more, we can scale, we can translate (change its position on the screen)  and also we can change the &#8220;center&#8221; for the transform. Usually the rotation happens from the center like above, but we could do it from closer to the left:</p>
<pre class='code transition-left'>element:hover {
  -webkit-transform:rotate(180deg);
  -webkit-transform-origin:30% 50%;
}
element {
  -webkit-transition:-webkit-transform 1s linear;
  -webkit-transform-origin:30% 50%;
}</pre>
<p>Or we could scale and move and rotate! (you might need to track it with you mouse to keep the animation! this is a demo after all!)</p>
<pre class='code transition-allover'>element:hover {
  -webkit-transform:rotate(180deg) scale(2) translate(-100%,0);
  -webkit-transform-origin:30% 50%;
}
element {
  -webkit-transition:-webkit-transform 1s linear;
  -webkit-transform-origin:30% 50%;
}</pre>
<div id='hey-look-at-me'>
<div id='untarget'>
<p>As the above eaxmple showed, hover is not always the best trigger for this. So lets use the <tt>:target</tt> pseudo-class. This is the pseudo-class that is applied when the element is the &#8216;target&#8217; of an anchor/url hash. e.g:</p>
<pre class='code'>&lt;div id='hey-look-at-me'&gt; &lt;div id='untarget'&gt; &lt;pre&gt;
CSS:
#hey-look-at-me:target pre {
  outline:2px solid red;
  color:#f0f;
}
#hey-look-at-me pre {
  -webkit-transition-property:outline, color;
  -webkit-transition-duration:500ms;
}
&lt;/pre&gt; &lt;/div&gt; &lt;/div&gt;

<a href='#hey-look-at-me'>target me!</a> <a href='#untarget'>untarget me!</a>
</pre>
</div>
</div>
<p><strong>NB:</strong> Notice how I nested the <tt>PRE</tt> to stop unwanted excessive screen movement.</p>
<p>So, what can we do with all this? Well, the culmination of the post, the Mac OSX style Dock menu, using no Javascript. Yes, that&#8217;s right a bulging docked menu, with no javascript.</p>
<p>Just so you remember, there <strong>no javascript</strong> in the demo.</p>
<p>Check out the <a href='/osx-dock'>Javascript free OSX Dock Menu Demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-03/more-webkit-goodies-css-transforms-and-transitions-the-osx-dock-example.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Webkit CSS Transitions &#8211; pretty cool stuff</title>
		<link>http://thechriswalker.net/2009-03/webkit-css-transitions-pretty-cool-stuff.html</link>
		<comments>http://thechriswalker.net/2009-03/webkit-css-transitions-pretty-cool-stuff.html#comments</comments>
		<pubDate>Tue, 10 Mar 2009 22:11:00 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=84</guid>
		<description><![CDATA[I recently read somewhere about developing web applications for the iPhone / Android browsers that you shouldn&#8217;t use Javascript Frameworks (e.g. jQuery) for animation in your web apps but instead use CSS3 transitions. I had no idea what these where, so had to look it up. Turns out it&#8217;s pretty much a WebKit only thing, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read somewhere about developing web applications for the iPhone / Android browsers that you shouldn&#8217;t use Javascript Frameworks (e.g. jQuery) for animation in your web apps but instead use CSS3 transitions. I had no idea what these where, so had to look it up. Turns out it&#8217;s pretty much a WebKit only thing, but that&#8217;s fine for iPhone (Safari) and Android (Chrome) Browsers.  </p>
<p>But what is it? Simply put, it&#8217;s a way to create a transition between to CSS states (hope that cleared <em>everything</em> up for you!)</p>
<p>Better, an example: You have two CSS rules for an element, say a link, and for it&#8217;s <tt>:hover</tt> state. like this:</p>
<div class="codecolorer-container css mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
<span style="color: #00AA00;">&#125;</span><br />
a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></div>
<p>Now usually, the browser would switch instantly between these two states, but with transitions we can slow it down into a smooth animation.</p>
<p>We can specify which propertys to transition and which to allow to change instantly. Here we can transition in the <tt>background</tt> and <tt>color</tt> properties.</p>
<div class="codecolorer-container css mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Add the transition properties! */</span><br />
&nbsp; &nbsp; -webkit-transition-property<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transition-duration<span style="color: #00AA00;">:</span> 600ms<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* you can control the acceleration curve here */</span><br />
&nbsp; &nbsp; -webkit-transition-timing-function<span style="color: #00AA00;">:</span> ease-in-out<span style="color: #00AA00;">;</span> <br />
<span style="color: #00AA00;">&#125;</span><br />
a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></div>
<p>Here&#8217;s two links, the they are identical except that the second has the transisions applied and if you&#8217;re using a WebKit based browser then it will fade nicely between states.</p>
<style type='text/css'>
a.tryme {
    display:inline-block;
    margin:5px 10px;
    background:#eee;
    color:#333;
    text-decoration:none;
    padding:5px 10px;
    border:2px solid #333;
    border-radius: 5px; 
    -moz-border-radius: 5px; 
    -webkit-border-radius: 5px;
}
a.trans {
    -webkit-transition-property: background-color, color;
    -webkit-transition-duration: 600ms;
    -webkit-transition-timing-function: ease-in-out;
}
a.tryme:hover {
    background:#333;
    color:#eee;
}
</style>
<p><a href='javascript:void(0);' class='tryme'>I will flick between states.</a> <a href='javascript:void(0);' class='tryme trans'>Do I fade or do I flick?</a></p>
<p>Next time I&#8217;ll go into a bit more detail and show how using CSS Transforms as well we can make an OSX Dock style menu using CSS alone!</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-03/webkit-css-transitions-pretty-cool-stuff.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
