<?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>Devirtuoso &#187; CSS</title>
	<atom:link href="http://www.devirtuoso.com/category/front-end-development/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devirtuoso.com</link>
	<description>Web Development Wickedness</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:16:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Triggering Navigation with Scrolling in JQuery</title>
		<link>http://www.devirtuoso.com/2012/01/triggering-navigation-with-scrolling-in-jquery/</link>
		<comments>http://www.devirtuoso.com/2012/01/triggering-navigation-with-scrolling-in-jquery/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 17:16:01 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[Scrolling]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1447</guid>
		<description><![CDATA[Scrolling as your sites main source of navigation is all the rage. With the amount of one page sites out there I thought it would be helpful to show how to trigger your navigation to changed based on how far you&#8217;ve scrolled down. What we&#8217;re building We&#8217;ll be creating a simple 1 page site. Actually [...]]]></description>
			<content:encoded><![CDATA[<p>Scrolling as your sites main source of navigation is all the rage.  With the amount of one page sites out there I thought it would be helpful to show how to trigger your navigation to changed based on how far you&#8217;ve scrolled down.<br />
<span id="more-1447"></span></p>
<h3>What we&#8217;re building</h3>
<p>We&#8217;ll be creating a simple 1 page site.  Actually we&#8217;ll just be stealing the code from the previous post on <a href="http://www.devirtuoso.com/2011/11/smooth-scrolling-in-jquery/">Smooth Scrolling in Jquery</a>, and adding in the navigation triggering bits.</p>
<div class="resources"><a class="Download" href="http://devirtuoso.com/Examples/ScrollTriggerNav/scrollTriggerNav.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/ScrollTriggerNav/" target="_blank">Example</a></div>
<h3>Steal the Previous Code</h3>
<p>We&#8217;re just going to steal the HTML and CSS from the previous post <a href="http://www.devirtuoso.com/2011/11/smooth-scrolling-in-jquery/" target="_blank">Smooth Scrolling in Jquery</a>.  There is nothing special, it&#8217;s just a navigation and a bunch of sections with a header and some text in them.  The headers have unique ids so we can reference them with the jQuery.  We&#8217;re more or less going to get rid of the jQuery and start a new.</p>
<p>Here is what we&#8217;re starting off with:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>Smooth Scrolling<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .container{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:300px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin:0 auto;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; .section{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin-top:60px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; .navigation{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position: fixed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background:white;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding:20px 20px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:100%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin-top:0px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top:0px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navigation&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#html&quot;</span>&gt;</span>HTML<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#javascript&quot;</span>&gt;</span>JavaScript<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#jquery&quot;</span>&gt;</span>jQuery<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#php&quot;</span>&gt;</span>PHP<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#css&quot;</span>&gt;</span>CSS<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html&quot;</span>&gt;</span>HTML<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span>&gt;</span>JavaScript<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery&quot;</span>&gt;</span>jQuery<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;php&quot;</span>&gt;</span>PHP<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css&quot;</span>&gt;</span>CSS<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>&nbsp; &nbsp; &nbsp; <br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
&nbsp; &nbsp; // JavaScript Will go Here<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<h3>The New CSS</h3>
<p>In new found code aquired by a five finger discount needs some styling.  Right now the navigation is plain and you can&#8217;t tell when an item is selected so we&#8217;re just going to add an .active class and perhaps beautify the list a bit.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/*<br />
Regular state of naviation<br />
*/</span><br />
a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span><br />
a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span><br />
a<span style="color: #3333ff;">:visited</span><span style="color: #00AA00;">&#123;</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;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</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;">3px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/*<br />
Active state of navigation<br />
*/</span><br />
<span style="color: #6666ff;">.active</span><span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span><br />
<span style="color: #6666ff;">.active</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span><br />
<span style="color: #6666ff;">.active</span><span style="color: #3333ff;">:visited<br />
</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000060</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/*<br />
Make the font of the list a little nicer to look at.<br />
*/</span><br />
<span style="color: #00AA00;">*</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">sans-serif</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;">#666</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<h3>The JQuery</h3>
<p>The first thing we need to know is how far each section is from the top.  So we&#8217;re going to write a function that we can pass in a navigation item and it will tell us how far that section is from the top.  Because we have our navigation at the top, we&#8217;ll have to make sure that the section triggers the change just before it reaches the navigation.  We&#8217;ll just subtract the height of the nav from the distance from the top.</p>
<p><img src="http://www.devirtuoso.com/wp-content/uploads/2012/01/imgScrollTriggerExplination.png" alt="Navigation Trigger Scrolling" /></p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Get Sections top position</span><br />
<span style="color: #003366; font-weight: bold;">function</span> getTargetTop<span style="color: #009900;">&#40;</span>elem<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//gets the id of the section header</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//from the navigation's href e.g. (&quot;#html&quot;)</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> elem.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Height of the navigation</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> offset <span style="color: #339933;">=</span> <span style="color: #CC0000;">60</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Gets the distance from the top and </span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//subtracts the height of the nav.</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span> <span style="color: #339933;">-</span> offset<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now that we can pull where each section is, we can now setup our navigation to scroll to a section when clicked.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Smooth scroll when user click link that starts with #</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href^=&quot;#&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//gets the distance from the top of the </span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//section refenced in the href.</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> getTargetTop<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//scrolls to that section.</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html, body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>scrollTop<span style="color: #339933;">:</span>target<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//prevent the browser from jumping down to section.</span><br />
&nbsp; &nbsp; event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>That takes care of the nav, but now comes the meat and potatoes.  The scrolling now has to trigger the navigation to change. We&#8217;ll create a function that goes through every section and sees if it&#8217;s at the top yet.  It&#8217;ll except 1 parameter which specifies how far the user has scrolled.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Pulling sections from main nav.</span><br />
<span style="color: #003366; font-weight: bold;">var</span> sections <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href^=&quot;#&quot;]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// Go through each section to see if it's at the top.</span><br />
<span style="color: #006600; font-style: italic;">// if it is add an active class</span><br />
<span style="color: #003366; font-weight: bold;">function</span> checkSectionSelected<span style="color: #009900;">&#40;</span>scrolledTo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//How close the top has to be to the section.</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> threshold <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> sections.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//get next nav item</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> section <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>sections<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//get the distance from top</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> getTargetTop<span style="color: #009900;">&#40;</span>section<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Check if section is at the top of the page.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scrolledTo <span style="color: #339933;">&gt;</span> target <span style="color: #339933;">-</span> threshold <span style="color: #339933;">&amp;&amp;</span> scrolledTo <span style="color: #339933;">&lt;</span> target <span style="color: #339933;">+</span> threshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//remove all selected elements</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sections.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//add current selected element.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; section.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The last thing we need to do is call the function when someone scrolls and when the page is first loaded.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Check if page is already scrolled to a section.</span><br />
checkSectionSelected<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scrollTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">scroll</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; checkSectionSelected<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scrollTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h3>That&#8217;s it!</h3>
<p>Now you have yourself a pretty sweet scrolling site.  You can also use this same principle to animate items on your page.  Too fun.</p>
<p>Here is all the code all together:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>Smooth Scrolling<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .container{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:300px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin:0 auto;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; .section{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin-top:60px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; .navigation{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position: fixed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background:white;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding:20px 20px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:100%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin-top:0px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top:0px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; a:link,<br />
&nbsp; &nbsp; &nbsp; &nbsp; a:hover,<br />
&nbsp; &nbsp; &nbsp; &nbsp; a:visited{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text-decoration:none;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color: #000;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding:3px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; .active:link,<br />
&nbsp; &nbsp; &nbsp; &nbsp; .active:hover,<br />
&nbsp; &nbsp; &nbsp; &nbsp; .active:visited<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color: #fff;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background: #000060;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; *{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-family: sans-serif;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color: #666;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navigation&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#html&quot;</span>&gt;</span>HTML<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#javascript&quot;</span>&gt;</span>JavaScript<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#jquery&quot;</span>&gt;</span>jQuery<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#php&quot;</span>&gt;</span>PHP<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#css&quot;</span>&gt;</span>CSS<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html&quot;</span>&gt;</span>HTML<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span>&gt;</span>JavaScript<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery&quot;</span>&gt;</span>jQuery<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;php&quot;</span>&gt;</span>PHP<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css&quot;</span>&gt;</span>CSS<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--Your HTML Content Goes HERE --&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>&nbsp; &nbsp; &nbsp; <br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
&nbsp; &nbsp; $(document).ready(function() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Get Sections top position<br />
&nbsp; &nbsp; &nbsp; &nbsp; function getTargetTop(elem){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //gets the id of the section header<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //from the navigation's href e.g. (&quot;#html&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var id = elem.attr(&quot;href&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Height of the navigation<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var offset = 60;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Gets the distance from the top and <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //subtracts the height of the nav.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $(id).offset().top - offset;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Smooth scroll when user click link that starts with #<br />
&nbsp; &nbsp; &nbsp; &nbsp; $('a[href^=&quot;#&quot;]').click(function(event) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //gets the distance from the top of the <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //section refenced in the href.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var target = getTargetTop($(this));<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //scrolls to that section.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('html, body').animate({scrollTop:target}, 500);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //prevent the browser from jumping down to section.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event.preventDefault();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; });<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Pulling sections from main nav.<br />
&nbsp; &nbsp; &nbsp; &nbsp; var sections = $('a[href^=&quot;#&quot;]');<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Go through each section to see if it's at the top.<br />
&nbsp; &nbsp; &nbsp; &nbsp; // if it is add an active class<br />
&nbsp; &nbsp; &nbsp; &nbsp; function checkSectionSelected(scrolledTo){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //How close the top has to be to the section.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var threshold = 100;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var i;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i <span style="color: #009900;">&lt; sections.length; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">//</span>get next nav item</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var section <span style="color: #66cc66;">=</span> $<span style="color: #66cc66;">&#40;</span>sections<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</span><br />
<br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">//</span>get the distance from top</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var <span style="color: #000066;">target</span> <span style="color: #66cc66;">=</span> getTargetTop<span style="color: #66cc66;">&#40;</span>section<span style="color: #66cc66;">&#41;</span>;</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">//</span>Check if section is at the top of the page.</span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if <span style="color: #66cc66;">&#40;</span>scrolledTo &gt;</span> target - threshold <span style="color: #ddbb00;">&amp;&amp; scrolledTo &lt; target + threshold) {</span><br />
<br />
<span style="color: #ddbb00;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //remove all selected elements</span><br />
<span style="color: #ddbb00;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sections.removeClass(&quot;active&quot;);</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //add current selected element.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; section.addClass(&quot;active&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Check if page is already scrolled to a section.<br />
&nbsp; &nbsp; &nbsp; &nbsp; checkSectionSelected($(window).scrollTop());<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; $(window).scroll(function(e){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; checkSectionSelected($(window).scrollTop())<br />
&nbsp; &nbsp; &nbsp; &nbsp; });<br />
<br />
<br />
<br />
&nbsp; &nbsp; });<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<div class="resources"><a class="Download" href="http://devirtuoso.com/Examples/ScrollTriggerNav/scrollTriggerNav.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/ScrollTriggerNav/" target="_blank">Example</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2012/01/triggering-navigation-with-scrolling-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minify and Gzip CSS in JavaScript</title>
		<link>http://www.devirtuoso.com/2011/09/minify-and-gzip-css-an-javascript/</link>
		<comments>http://www.devirtuoso.com/2011/09/minify-and-gzip-css-an-javascript/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 13:30:03 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[development Tools]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[minify]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1404</guid>
		<description><![CDATA[Found a pretty cool site.  It allows users to minify and compress both their CSS and JavaScript. So I thought I would just share it with you so you can bask in it&#8217;s speed inducing glory. zBugs Although still in beta at this point in time, zBugs has an easy to use interface which makes [...]]]></description>
			<content:encoded><![CDATA[<p>Found a pretty cool site.  It allows users to minify and compress both their CSS and JavaScript. So I thought I would just share it with you so you can bask in it&#8217;s speed inducing glory.<span id="more-1404"></span></p>
<h3>zBugs</h3>
<p>Although still in beta at this point in time, zBugs has an easy to use interface which makes compressing and minifying easy.  The coolest thing of all, if you sign up they give you a FREE CDN link to your compressed and minified files&#8230;..SWEEET.  They also have an xml sitemap generator, which is handy. Be sure to check them out, well worth the look in my humble opinion.</p>
<p><a title="zBugs - Minify and Compress CSS and JavaScript" href="http://www.zbugs.com" target="_blank">http://www.zbugs.com</a></p>
<p><a href="http://www.zbugs.com"><img class="alignnone size-full wp-image-1405" title="zBugs" src="http://www.devirtuoso.com/wp-content/uploads/2011/09/zBugs.jpg" alt="zBugs - Minify and Compress CSS and JavaScipt" width="500" height="210" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2011/09/minify-and-gzip-css-an-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a 3D Scrolling Carousel with CSS3 and JQuery</title>
		<link>http://www.devirtuoso.com/2011/09/creating-a-3d-scrolling-carousel-with-css3-and-jquery/</link>
		<comments>http://www.devirtuoso.com/2011/09/creating-a-3d-scrolling-carousel-with-css3-and-jquery/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 18:57:36 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1371</guid>
		<description><![CDATA[How do you make your CSS3 awesome? By creating something 3D of course. I thought that was a given This tutorial will show how to do just that&#8230;.awesomify your CSS3. CSS3 Scrolling Carousel What we&#8217;re trying to build here is a carousel that scrolls when the user uses the browser&#8217;s scroll bar. Allowing the user [...]]]></description>
			<content:encoded><![CDATA[<p>How do you make your CSS3 awesome? By creating something 3D of course. I thought that was a given <img src='http://www.devirtuoso.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  This tutorial will show how to do just that&#8230;.awesomify your CSS3.<br />
<span id="more-1371"></span></p>
<h3>CSS3 Scrolling Carousel</h3>
<p>What we&#8217;re trying to build here is a carousel that scrolls when the user uses the browser&#8217;s scroll bar.  Allowing the user to navigate in a way they&#8217;re already familiar with.</p>
<h2 style="color:red">Note: This will only work with webkit browsers (I found Chrome to be finicky, works on mac&#8230;not so much on pc). Safari is your best bet. Transform 3D still isn&#8217;t fully supported yet.</h2>
<p></p>
<div class="resources"><a class="Download" href="http://devirtuoso.com/Examples/CSS3Carousel/css3Carousel.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/CSS3Carousel">Example</a></div>
<h3>The HTML</h3>
<p>Really we just need something to scroll, and a container to hold everything pretty simple HTML.  We&#8217;re just going to make sure each item has a class associated with it so we can reference it later in jQuery.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>3d Carousel<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- CSS will go here --&gt;</span><br />
&nbsp; <br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide1&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 1<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 2<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide3&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 3<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide4&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 4<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide5&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 5<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide6&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 6<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;</span> &gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- jQuery will go here --&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<h3>The CSS</h3>
<p>There are 3 important things that are going to happen in the CSS.</p>
<ol>
<li>Give the body a big min-height to enable scrolling.</li>
<li>Give our main container a fixed position so it doesn&#8217;t move when we scroll and setting the transform style so it acts like a 3d space. (Things closer to the user are in front of things further away)</li>
<li>Setup each slide to be position absolute to move freely.</li>
</ol>
<p>Most of the heavy lifting will be done in the jQuery.  The CSS will just set up each slide so it can move freely in 3d space, and make sure the screen has a scroll bar.  The jQuery will link the scroll bar to the each slide.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">body<span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Enable the scroll bar */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">5000px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Centering the carousel */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #993333;">auto</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
<span style="color: #cc00cc;">#main</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Make sure everything works in a 3d space. */</span><br />
&nbsp; &nbsp; -webkit-transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Adjusting the perspective...make it look more roundish */</span><br />
&nbsp; &nbsp; -webkit-perspective<span style="color: #00AA00;">:</span> <span style="color: #933;">1800px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Rotating the angle a bit so it isn't face on */</span> &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> rotateY<span style="color: #00AA00;">&#40;</span>10deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Make sure the carousel doesn't move when we scroll */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
.slide<span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Make sure it can move freely */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Set the dimensions */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Positioning text in the middle of the box */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* An easing effect*/</span><br />
&nbsp; &nbsp; -webkit-transition<span style="color: #00AA00;">:</span> all 800ms cubic-bezier<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0.260</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.860</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.440</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.985</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <br />
<br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/*<br />
* Change the colors of each slide so we can tell them apart.<br />
*/</span><br />
<br />
<span style="color: #cc00cc;">#slide1</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: #993333;">green</span><span style="color: #00AA00;">;</span> &nbsp;<br />
<span style="color: #00AA00;">&#125;</span> &nbsp; &nbsp;<br />
<span style="color: #cc00cc;">#slide2</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: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span> &nbsp;<br />
<span style="color: #00AA00;">&#125;</span> &nbsp; &nbsp;<br />
<span style="color: #cc00cc;">#slide3</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span>pink<span style="color: #00AA00;">;</span> &nbsp;<br />
<span style="color: #00AA00;">&#125;</span> &nbsp; &nbsp;<br />
<span style="color: #cc00cc;">#slide4</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span>orange<span style="color: #00AA00;">;</span> &nbsp;<br />
<span style="color: #00AA00;">&#125;</span> &nbsp; &nbsp;<br />
<span style="color: #cc00cc;">#slide5</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: #993333;">silver</span><span style="color: #00AA00;">;</span> &nbsp;<br />
<span style="color: #00AA00;">&#125;</span> &nbsp; &nbsp;<br />
<span style="color: #cc00cc;">#slide6</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: #993333;">purple</span><span style="color: #00AA00;">;</span> &nbsp;<br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>A couple of things that were used that might need some explanation.  </p>
<ol>
<li>-webkit-perspective: 1800px; &#8211; The -webkit-perspective adjusts how the 3d will look, or in camera terms what kind of lens. Do we want it to look fish eye or relatively flat.</li>
<li>-webkit-transform: rotateY(10deg); &#8211; This just rotates everything along the y axis.</li>
<li>-webkit-transition: all 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985);  &#8211; cubic-bezier just creates a nice easing effect after a user stops scrolling.  You can play around with the values to get it how you want it to look.  This was just used to increase the geekiness of the code. <img src='http://www.devirtuoso.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>
<h3>The JQuery</h3>
<p>So here comes the cool part. The JQuery sets up each slide on the carousel. Once a user scrolls, it then updates each slide in the carousel, rotating it accordingly.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #006600; font-style: italic;">//Go through each slide.</span><br />
&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.slide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Figure out how many slides, then give each slide a slice of the pie.</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> length <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.slide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> degree <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #CC0000;">360</span> <span style="color: #339933;">/</span> length<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Set the slide's reference to the starting point on the carousel.</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">,</span>degree <span style="color: #339933;">*</span> index<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Position the slide on the carousel using css</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;-webkit-transform&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'translate3d(0,100%,0) rotateX('</span><span style="color: #339933;">+</span>degree <span style="color: #339933;">*</span> index<span style="color: #339933;">+</span><span style="color: #3366CC;">'deg) translate3d(0,100%,0)'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <br />
&nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//When the window scrolls....</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">scroll</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Figure out how far down we've scrolled. (Value from 0 - 1)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> percent <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scrollTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//The new rotation based on how far down the user scrolled</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; degrees <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>percent <span style="color: #339933;">*</span> <span style="color: #CC0000;">360</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Go through each slide..</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.slide'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> startDegree <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Add the degrees to whatever the starting point was.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> val <span style="color: #339933;">=</span> degrees <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span>startDegree<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Apply the css</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;-webkit-transform&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'translate3d(0,100%,0) rotateX('</span><span style="color: #339933;">+</span>val<span style="color: #339933;">+</span><span style="color: #3366CC;">'deg) translate3d(0,100%,0)'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>A little explanation. We first figure out where each slide should be on the carousel, by figuring out how many degrees should separate each slide.  So we divide 360 degrees by how many slides we have.  That should tell us where on the circle each slide should reside.</p>
<p><img src="http://www.devirtuoso.com/wp-content/uploads/2011/09/degrees.png" alt="Degrees around the carousel" /></p>
<p>As for the CSS transform, we first position the slide in the center of the carousel.  Rotate the slide to the desired degree.  Then push it away from the center along the axis that it was rotated.</p>
<p><img src="http://www.devirtuoso.com/wp-content/uploads/2011/09/cssTransformation.png" alt="css webkit transform explination" /></p>
<h3>That&#8217;s it</h3>
<p>Feel free to play around with the values.  You can easily change it from verticle to horizontal by playing around with the axis it rotates and which direction it is pushed with the translate3d.  Have fun with it!</p>
<p>Here is everything all together:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>3d Carousel<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;</span><br />
&nbsp; <br />
&nbsp; body{<br />
&nbsp; &nbsp; &nbsp; /* Enable the scroll bar */<br />
&nbsp; &nbsp; &nbsp; min-height:5000px;<br />
<br />
&nbsp; &nbsp; &nbsp; /* Centering the carousel */<br />
&nbsp; &nbsp; &nbsp; width:200px;<br />
&nbsp; &nbsp; &nbsp; margin:30px auto 0px;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; }<br />
<br />
&nbsp; #main{<br />
&nbsp; &nbsp; &nbsp; /* Make sure everything works in a 3d space. */<br />
&nbsp; &nbsp; &nbsp; -webkit-transform-style: preserve-3d;<br />
<br />
&nbsp; &nbsp; &nbsp; /* Adjusting the perspective...make it look more roundish */<br />
&nbsp; &nbsp; &nbsp; -webkit-perspective: 1800px; <br />
<br />
&nbsp; &nbsp; &nbsp; /* Rotating the angle a bit so it isn't face on */ &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; -webkit-transform: rotateY(10deg);<br />
<br />
&nbsp; &nbsp; &nbsp; /* Make sure the carousel doesn't move when we scroll */<br />
&nbsp; &nbsp; &nbsp; position: fixed;<br />
&nbsp; }<br />
&nbsp; .slide{<br />
&nbsp; &nbsp; &nbsp; /* Make sure it can move freely */<br />
&nbsp; &nbsp; &nbsp; position:absolute;<br />
&nbsp; &nbsp; &nbsp; display:block;<br />
<br />
&nbsp; &nbsp; &nbsp; /* Set the dimensions */<br />
&nbsp; &nbsp; &nbsp; width:200px;<br />
&nbsp; &nbsp; &nbsp; height:200px;<br />
<br />
&nbsp; &nbsp; &nbsp; /* Positioning text in the middle of the box */<br />
&nbsp; &nbsp; &nbsp; text-align:center;<br />
&nbsp; &nbsp; &nbsp; line-height:200px;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; /* An easing effect*/<br />
&nbsp; &nbsp; &nbsp; -webkit-transition: all 800ms cubic-bezier(0.260, 0.860, 0.440, 0.985); <br />
<br />
&nbsp; }<br />
<br />
&nbsp; /*<br />
&nbsp; * Change the colors of each slide so we can tell them apart.<br />
&nbsp; */<br />
<br />
&nbsp; #slide1{<br />
&nbsp; &nbsp; &nbsp; background:green; &nbsp;<br />
&nbsp; } &nbsp; &nbsp;<br />
&nbsp; #slide2{<br />
&nbsp; &nbsp; &nbsp; background:blue; &nbsp;<br />
&nbsp; } &nbsp; &nbsp;<br />
&nbsp; #slide3{<br />
&nbsp; &nbsp; &nbsp; background:pink; &nbsp;<br />
&nbsp; } &nbsp; &nbsp;<br />
&nbsp; #slide4{<br />
&nbsp; &nbsp; &nbsp; background:orange; &nbsp;<br />
&nbsp; } &nbsp; &nbsp;<br />
&nbsp; #slide5{<br />
&nbsp; &nbsp; &nbsp; background:silver; &nbsp;<br />
&nbsp; } &nbsp; &nbsp;<br />
&nbsp; #slide6{<br />
&nbsp; &nbsp; &nbsp; background:purple; &nbsp;<br />
&nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide1&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 1<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 2<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide3&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 3<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide4&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 4<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide5&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 5<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide6&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;slide&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; Slide 6<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;</span> &gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
&nbsp; &nbsp; $(document).ready(function() {<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; //Go through each slide.<br />
&nbsp; &nbsp; &nbsp; $('.slide').each(function(index) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Figure out how many slides, then give each slide a slice of the pie.<br />
&nbsp; &nbsp; &nbsp; &nbsp; var length = $('.slide').length;<br />
&nbsp; &nbsp; &nbsp; &nbsp; var degree = (360 / length) | 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Set a reference to the starting point on the carousel.<br />
&nbsp; &nbsp; &nbsp; &nbsp; $(this).attr(&quot;data&quot;,degree * index)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Position the slide on the carousel using css<br />
&nbsp; &nbsp; &nbsp; &nbsp; //-webkit-transform: Pushes the whole carousel down from top : Rotates the carousel : The radius of the carousel<br />
&nbsp; &nbsp; &nbsp; &nbsp; $(this).css({&quot;-webkit-transform&quot;: 'translate3d(0,100%,0) rotateX('+degree * index+'deg) translate3d(0,100%,0)'});<br />
&nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //When the window scrolls....<br />
&nbsp; &nbsp; &nbsp; &nbsp; $(window).scroll(function(e) {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Figure out how far down we've scrolled. (Value from 0 - 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var percent = (($(this).scrollTop()) / ($('body').height() - $(window).height()));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //The new rotation based on how far down the user scrolled<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; degrees = (percent * 360) | 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Go through each slide..<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('.slide').each(function(index) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var startDegree = $(this).attr(&quot;data&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Add the degrees to whatever the starting point was.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var val = degrees + parseInt(startDegree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Apply the css<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //-webkit-transform: Pushes the whole carousel down from top : Rotates the carousel : The keeps the radius of the carousel<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(this).css({&quot;-webkit-transform&quot;: 'translate3d(0,100%,0) rotateX('+val+'deg) translate3d(0,100%,0)'});<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; });<br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<div class="resources"><a class="Download" href="http://devirtuoso.com/Examples/CSS3Carousel/css3Carousel.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/CSS3Carousel">Example</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2011/09/creating-a-3d-scrolling-carousel-with-css3-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toggle Switches with JQuery and Checkboxes</title>
		<link>http://www.devirtuoso.com/2011/05/toggle-switches-with-jquery-and-checkboxes/</link>
		<comments>http://www.devirtuoso.com/2011/05/toggle-switches-with-jquery-and-checkboxes/#comments</comments>
		<pubDate>Wed, 25 May 2011 14:30:58 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1324</guid>
		<description><![CDATA[iOS style checkboxes (toggle switches) are far more user friendly than ye ol&#8217; browser checkboxes.  Without feeling to sorry for your browser checkboxes, we&#8217;re going to go through creating new toggle switch hotness with jQuery. What are we building? Well I&#8217;m glad you asked.  We&#8217;re going to take a progressive enhancement approach to this.  We [...]]]></description>
			<content:encoded><![CDATA[<p>iOS style checkboxes (toggle switches) are far more user friendly than ye ol&#8217; browser checkboxes.  Without feeling to sorry for your browser checkboxes, we&#8217;re going to go through creating new toggle switch hotness with jQuery.<br />
<span id="more-1324"></span></p>
<h2>What are we building?</h2>
<p>Well I&#8217;m glad you asked.  We&#8217;re going to take a progressive enhancement approach to this.  We want to make sure that the checkboxes still work if JavaScript is turned off.  So with jQuery we&#8217;ll add the new toggle switches, and make them check off the hidden checkboxes when clicked.</p>
<div class="resources"><a class="Download" href="http://www.devirtuoso.com/Examples/toggleSwitch/toggleSwitch.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/toggleSwitch/" target="_blank">Example</a></div>
<h2>Getting Started: <span>The HTML</span></h2>
<p>Nothing to crazy going on here.  It&#8217;s just a simple form with some checkboxes.  I added a class to the checkboxes just for ease of use.  Not really necessary if you&#8217;d rather reference them by some other means.  Also I gave the body tag a class of &#8220;nojs&#8221; so we can change this to &#8220;js&#8221; with JavaScript.  This way we can react appropriately when someone doesn&#8217;t have javascript enabled.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nojs&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span>Toggle Checkboxes<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!--</span><br />
<span style="color: #808080; font-style: italic;"> &nbsp; &nbsp; &nbsp;Enjoy Web</span><br />
<span style="color: #808080; font-style: italic;"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enjoy_web&quot;</span>&gt;</span>Do you enjoy web development?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enjoy_web&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enjoy_web&quot;</span> <span style="color: #000066;">checked</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!--</span><br />
<span style="color: #808080; font-style: italic;"> &nbsp; &nbsp; &nbsp;Hate IE</span><br />
<span style="color: #808080; font-style: italic;"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enjoy_web&quot;</span>&gt;</span>Do you hate IE?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hate_ie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hate_ie&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!--</span><br />
<span style="color: #808080; font-style: italic;"> &nbsp; &nbsp; &nbsp;Sad Pandas</span><br />
<span style="color: #808080; font-style: italic;"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enjoy_web&quot;</span>&gt;</span>Do pandas make you sad?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sad_panda&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sad_panda&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;showCheckboxes&quot;</span>&gt;</span>Show Checkboxes<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span></div></td></tr></tbody></table></div>
<h2>The jQuery</h2>
<p>The first thing we need to tackle is progressive enhancement.  So we&#8217;re just going to change the body class to &#8220;js&#8221;, so now in our css we can hide all checkboxes when the javascript is enabled.</p>
<p>After that we add an anchor tag after each checkbox.  This will be our toggle switch with the magic of css styling.  When we create this anchor we&#8217;ll add a ref attribute which reference the checkbox that it will affect.  Also we&#8217;ll add a checked class to the anchor tag if the checkbox is already checked.</p>
<p>Then it just comes down to creating a click event for our new anchor tag.  This will just toggle on and off a checked attribute of the checkbox referenced in the anchor&#8217;s ref tag.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; Progressive enhancement. &nbsp;If javascript is enabled we change the body class. &nbsp;Which in turn hides the checkboxes with css.<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;js&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; Add toggle switch after each checkbox. &nbsp;If checked, then toggle the switch.<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.checkbox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;&lt;a href='#' class='toggle checked' ref='&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;'&gt;&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;&lt;a href='#' class='toggle' ref='&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;'&gt;&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #006600; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; When the toggle switch is clicked, check off / de-select the associated checkbox<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.toggle'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> checkboxID <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ref&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> checkbox <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span><span style="color: #339933;">+</span>checkboxID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checkbox.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;checkbox.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;checkbox.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;checked&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;checked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h2>CSS: <span>The Styling of the Toggle Switch</span></h2>
<p>There is nothing to crazy here.  If you&#8217;ve ever done a sprite button, you won&#8217;t find too much new here.  We&#8217;re just giving the anchor a background of toggle switch graphic and shifting it up and down depending on whether it has a checked class or not.</p>
<p>Also we&#8217;re hiding all checkboxes if javascript is enabled.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.js</span> .checkbox<span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
.toggle<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: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;toggle.png&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">70px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">22px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
<span style="color: #6666ff;">.toggle</span>.checked<span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<h2>That&#8217;s it</h2>
<p>Not too hard was it?  You can play around with the code at <a href="http://jsfiddle.net/devirtuoso/KnGAc/" target="_blank">jsfiddle</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2011/05/toggle-switches-with-jquery-and-checkboxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebKit Animated Valentines Heart</title>
		<link>http://www.devirtuoso.com/2011/02/webkit-animated-valentines-heart/</link>
		<comments>http://www.devirtuoso.com/2011/02/webkit-animated-valentines-heart/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 14:57:22 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Webkit]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1308</guid>
		<description><![CDATA[Tis the season to be romantic with geekery. So why not give your loved one a throbbing Webkit heart&#8230;nothing says love like Webkit&#8230;trust me. In this post I&#8217;ll show you a quick way to animate a heart image in a love inducing rhythmic motion. Webkit Animation It&#8217;s a pretty simple build, one image and some [...]]]></description>
			<content:encoded><![CDATA[<p>Tis the season to be romantic with geekery.  So why not give your loved one a throbbing Webkit heart&#8230;nothing says love like Webkit&#8230;trust me. <img src='http://www.devirtuoso.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   In this post I&#8217;ll show you a quick way to animate a heart image in a love inducing rhythmic motion.<br />
<span id="more-1308"></span></p>
<h2>Webkit Animation</h2>
<p>It&#8217;s a pretty simple build, one image and some handy dandy webkit key frames.  So seeing as this uses webkit a little disclaimer is in order&#8230;ahem&#8230;<strong>THIS ONLY WORKS IN CHROME AND SAFARI</strong>.</p>
<div class="resources"><a target="_blank" href="http://www.devirtuoso.com/Examples/Valentines/heart.zip" class="Download">Download</a> <a target="_blank" href="http://www.devirtuoso.com/Examples/Valentines/" class="Example">Example</a></div>
<h2>Getting Started : <span>The HTML</span></h2>
<p>It doesn&#8217;t get much simpler than this. Simply put an image of your heart on the page.  I also put a message just for kicks.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span>Happy Valentines<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">img</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;heart.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></div></td></tr></tbody></table></div>
<h2>Webkit Wickedness</h2>
<p>And now comes the brains of the operation, Webkit.  We setup our img tag with the specifics of our animation (name, duration,looping and easing)..all the essential nutrients for a kick ass animation. After that we assign key frames to that animation.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">img <span style="color: #00AA00;">&#123;</span><br />
&nbsp; -webkit-animation-name<span style="color: #00AA00;">:</span> resize<span style="color: #00AA00;">;</span><br />
&nbsp; -webkit-animation-duration<span style="color: #00AA00;">:</span> 1.3s<span style="color: #00AA00;">;</span><br />
&nbsp; -webkit-animation-iteration-count<span style="color: #00AA00;">:</span> infinite<span style="color: #00AA00;">;</span><br />
&nbsp; -webkit-animation-timing-function<span style="color: #00AA00;">:</span> ease-in-out<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #a1a100;">@-webkit-keyframes resize {</span><br />
&nbsp; <span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; -moz-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span> &nbsp;<br />
&nbsp; <span style="color: #933;">15%</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; -moz-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span>.8<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span>.8<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; <span style="color: #933;">30%</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; -moz-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>&nbsp; &nbsp; <br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; <span style="color: #933;">50%</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; -moz-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span>.8<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span>.8<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; <span style="color: #933;">70%</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; -moz-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
<br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<h2>The Webkit Explanation</h2>
<p>The animation is assigned to the img based on the animation name that we gave it (resize).  Once the selector is good to go we can assign any CSS at any point in the animation just by specifying at what percentage you want it appear at.  For example, at 0% we have it starting at full size, then at 15% we shrink it down&#8230;and repeat.  That&#8217;s all there is to it.  Just be sure you use this knowledge on someone that is worthy of such excellence. Happy Valentines!</p>
<div class="resources"><a target="_blank" href="http://www.devirtuoso.com/Examples/Valentines/heart.zip" class="Download">Download</a> <a target="_blank" href="http://www.devirtuoso.com/Examples/Valentines/" class="Example">Example</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2011/02/webkit-animated-valentines-heart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tooltips the JQuery way</title>
		<link>http://www.devirtuoso.com/2011/02/tooltips-the-jquery-way/</link>
		<comments>http://www.devirtuoso.com/2011/02/tooltips-the-jquery-way/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 19:39:30 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1292</guid>
		<description><![CDATA[When it comes to forms, keeping things easy and clutter free for the user is key. In this tutorial I&#8217;ll show you how to create tooltips that helps users without the clutter. What we&#8217;re building We are going to be adding functionality to the label tag. There will be a new attribute that you can [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to forms, keeping things easy and clutter free for the user is key.  In this tutorial I&#8217;ll show you how to create tooltips that helps users without the clutter.<br />
<span id="more-1292"></span></p>
<h2>What we&#8217;re building</h2>
<p>We are going to be adding functionality to the label tag.  There will be a new attribute that you can add called &#8220;helpText&#8221; that will end up as your tooltip.  For decluttering purposes, we&#8217;ll be replacing the label text with the tooltip text on rollover.</p>
<div class="resources"><a class="Download" href="http://www.devirtuoso.com/Examples/jqueryHelpLabel/jqueryToolTip.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/jqueryHelpLabel/" target="_blank">Example</a></div>
<h2>Building the Form</h2>
<p>This will work with any standard form. The only difference will be the labels.  We will be adding a helpText attribute that jQuery will take and make into awesome tooltip.<br />
So here is the simple form:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;smaple_form&quot;</span>&gt;</span>Smaple Form<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #000066;">accept-charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample_label&quot;</span> helpText<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter your name here.&quot;</span>&gt;</span>Name <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample_label&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample_label&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;website&quot;</span> helpText<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter your website here.&quot;</span>&gt;</span>Favorite Website<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span></div></td></tr></tbody></table></div>
<h2>jQuery It Up : <span>Handling the Label&#8217;s Rollover</span></h2>
<p>So first thing we&#8217;re going to do is handle the rollover state of the label.  We&#8217;ll be hiding the label and creating the help text in this function.  Perhaps a little fading animation to make it a little more polished.  Just a note, we&#8217;ll be using a JQuery plugin called <a href="http://cherne.net/brian/resources/jquery.hoverIntent.html" target="_blank">Hover Intent</a>.  This is a fantastic plugin that makes sure the user is intentionally hovering over our label and not just by passing by.  The user will have to hover over our label for a second for it to activate.<br />
Here is the <strong>jQuery</strong> for the rollover state:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; <span style="color: #006600; font-style: italic;">//Label hover handler</span><br />
&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'label'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hoverIntent</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Get the Help Text</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> helpText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;helpText&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Make sure the label has the helpText attribute before carrying on.</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>helpText <span style="color: #339933;">!=</span> undefined <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> helpText <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Hide label</span><br />
&nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Create help text if it doesn't already exist</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.help&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Create Tooltip then fade it in.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;div class=&quot;</span>help<span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">+</span>helpText<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.help'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h2>Tooltip Removal</h2>
<p>Next we&#8217;ll tackle removing the tooltip when the user moves their cursor off the help text.  We&#8217;ll need to use <a href="http://api.jquery.com/live/" target="_blank">jQuery&#8217;s live() function</a> as we&#8217;ll be creating and destroying these tooltips, and we&#8217;ll want jQuery to assign a mouseout event handler to each one we create. In this event handler we just show the label again and remove the tooltip.<br />
Here is the jQuery for the tooltip:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Help mouse out handler.</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.help'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseout'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; <span style="color: #006600; font-style: italic;">//Show the label again.</span><br />
&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'label'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #006600; font-style: italic;">//Remove the help text</span><br />
&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h2>CSS Styles</h2>
<p>So as of right now your tooltip should work.  Of course you can style everything with CSS to how you like.  The tooltip uses the class help.</p>
<p>Here is the CSS I used:</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">label<span style="color: #00AA00;">,</span><br />
.<span style="color: #993333;">help</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.3em</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">.2em</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
input<span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
h1<span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.7em</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.1em</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<br />
.<span style="color: #993333;">help</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1em</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.4em</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">help</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<h2>Good to Go</h2>
<p>The last thing you need to do is sit back and enjoy you&#8217;re masterpiece.  Enjoy!</p>
<p>Here is all the code together:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>jQuery Help Labels<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;description&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Using jQuery to make a handle help rollover&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;keywords&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery label animate help rollover&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">link</span></a> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/reset.css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">link</span></a> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/style.css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span><br />
&nbsp; <br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;smaple_form&quot;</span>&gt;</span>Smaple Form<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #000066;">accept-charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample_label&quot;</span> helpText<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter your name here.&quot;</span>&gt;</span>Name <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample_label&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample_label&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;website&quot;</span> helpText<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter your website here.&quot;</span>&gt;</span>Favorite Website<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;website&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">li</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">ul</span></a>&gt;</span><br />
<br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!--</span><br />
<span style="color: #808080; font-style: italic;">Load Hover Intent</span><br />
<span style="color: #808080; font-style: italic;">--&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hoverIntent.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span><br />
$(document).ready(function() {<br />
<br />
&nbsp; //Label hover handler<br />
&nbsp; $('label').hoverIntent(function() {<br />
<br />
&nbsp; &nbsp; //Get the Help Text<br />
&nbsp; &nbsp; var helpText = $(this).attr(&quot;helpText&quot;);<br />
<br />
&nbsp; &nbsp; //Make sure the label has the helpText attribute before carrying on.<br />
&nbsp; &nbsp; if (helpText != undefined <span style="color: #ddbb00;">&amp;&amp; helpText != &quot;&quot;) {</span><br />
<br />
<span style="color: #ddbb00;"> &nbsp; &nbsp; &nbsp;//Hide label</span><br />
<span style="color: #ddbb00;"> &nbsp; &nbsp; &nbsp;$(this).stop().fadeOut(200);</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; //Create help text if it doesn't already exist<br />
&nbsp; &nbsp; &nbsp; if ($(this).siblings(&quot;.help&quot;).length == 0) {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Create Tooltip then fade it in.<br />
&nbsp; &nbsp; &nbsp; &nbsp; $(this).after(&quot;<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'help'</span>&gt;</span>&quot;+helpText+&quot;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; $('.help').stop().delay(200).fadeIn(200);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; },function(){});<br />
<br />
<br />
&nbsp; //Help mouse out handler.<br />
&nbsp; $('.help').live('mouseout',function() {<br />
<br />
&nbsp; &nbsp; //Show the label again.<br />
&nbsp; &nbsp; $(this).siblings('label').stop().show();<br />
<br />
&nbsp; &nbsp; //Remove the help text<br />
&nbsp; &nbsp; $(this).remove();<br />
<br />
&nbsp; });<br />
<br />
});<br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<div class="resources"><a class="Download" href="http://www.devirtuoso.com/Examples/jqueryHelpLabel/jqueryToolTip.zip" target="_blank">Download</a> <a class="Example" href="http://www.devirtuoso.com/Examples/jqueryHelpLabel/" target="_blank">Example</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2011/02/tooltips-the-jquery-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Using Google Fonts for your website</title>
		<link>http://www.devirtuoso.com/2010/08/quick-tip-using-google-fonts-for-your-website/</link>
		<comments>http://www.devirtuoso.com/2010/08/quick-tip-using-google-fonts-for-your-website/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 17:08:15 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1221</guid>
		<description><![CDATA[Google has offered yet another fantastic service that allows you to add new free fonts to your web pages. This article will give you a quick run down on how to do this. Google Font Directory Tired of using the same ol&#8217; fonts for every web page? I know I am. Google offers a directory [...]]]></description>
			<content:encoded><![CDATA[<p>Google has offered yet another fantastic service that allows you to add new free fonts to your web pages. This article will give you a quick run down on how to do this.</p>
<p><span id="more-1221"></span></p>
<link href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'>
<style type="text/css" media="screen">
	.content h2 { 
		font-family: 'Reenie Beanie', arial, serif !important; 
		font-size:2.2em !important;
		}
</style>
<h2>Google Font Directory</h2>
<p>Tired of using the same ol&#8217; fonts for every web page?  I know I am. Google offers a directory of fonts that you can quickly add to your website with 2 lines of code.  Doesn&#8217;t get much easier.</p>
<h2><span>Step 1:</span> Select a Font</h2>
<p>Visit the <a href="http://code.google.com/webfonts" target="blank">Google Font Directory</a> and pick out a font.  There isn&#8217;t a huge list, but what they do have is nice and clean.</p>
<h2><span>Step 2:</span> Get the Code</h2>
<p>After you click on the font you want, just click on &#8220;Get the code&#8221;. Google offers up 2 lines of code.  One a CSS include for the font you selected, and the CSS to implement it.</p>
<h2><span>Step 3:</span> Use the Code</h2>
<p>Copy and paste the code into your document.  El finito.  This is the code I used for the headers in this article.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">link</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'http://fonts.googleapis.com/css?family=Reenie+Beanie'</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'stylesheet'</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'text/css'</span>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; h2 { font-family: 'Reenie Beanie', arial, serif; }<br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2010/08/quick-tip-using-google-fonts-for-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Development Tool: Zen Coding</title>
		<link>http://www.devirtuoso.com/2010/08/development-tool-zen-coding/</link>
		<comments>http://www.devirtuoso.com/2010/08/development-tool-zen-coding/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 13:25:11 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[development Tools]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1194</guid>
		<description><![CDATA[Zen Coding is by far my favorite development tool.  It makes website development quick and easy, and like the name suggests it instills a state of calm So What is Zen Coding? Zen Coding is a variety of snippets to make your life easier.  Their demo video explains it all too well. Zen Coding v0.5 [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Zen Coding" href="http://http://code.google.com/p/zen-coding/" target="_blank">Zen Coding</a> is by far my favorite development tool.  It makes website development quick and easy, and like the name suggests it instills a state of calm <img src='http://www.devirtuoso.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<span id="more-1194"></span></p>
<h3>So What is Zen Coding?</h3>
<p>Zen Coding is a variety of snippets to make your life easier.  Their demo video explains it all too well.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="275" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7405114&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="275" src="http://vimeo.com/moogaloop.swf?clip_id=7405114&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7405114">Zen Coding v0.5</a> from <a href="http://vimeo.com/user2060676">Sergey Chikuyonok</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The best part about all of this is how many IDEs it&#8217;s available for.  There is 21 versions of it in the downloads.  <a title="Zen Coding Download List" href="http://code.google.com/p/zen-coding/downloads/list" target="_blank">Check them out</a>, there is probably one for your favorite IDE.</p>
<p>Be sure to get your copy at <a title="Zen Coding" href="http://code.google.com/p/zen-coding/" target="_blank">Zen Coding&#8217;s website</a>.  I guarantee you&#8217;ll love it.  Haven&#8217;t met a developer who hasn&#8217;t.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2010/08/development-tool-zen-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Development Tool: CSS3 PIE for Internet Explorer</title>
		<link>http://www.devirtuoso.com/2010/08/development-tool-css3-pie-for-internet-explorer/</link>
		<comments>http://www.devirtuoso.com/2010/08/development-tool-css3-pie-for-internet-explorer/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 14:12:06 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[development Tools]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=1184</guid>
		<description><![CDATA[Gone are the days of using images for rounded corners.  With CSS3 PIE internet explorer can now use CSS3 awesomeness. What is it? Quite simply CSS3 PIE is a file that you include in your CSS definitions to enable CSS3 styling (rounded corners, shadows, etc.) Internet Explorer is one of the last browsers that doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Gone are the days of using images for rounded corners.  With<a href="http://css3pie.com/" target="_blank"> CSS3 PIE</a> internet explorer can now use CSS3 awesomeness.</p>
<p><span id="more-1184"></span></p>
<h3>What is it?</h3>
<p>Quite simply <a href="http://css3pie.com/" target="_blank">CSS3 PIE</a> is a file that you include in your CSS definitions to enable CSS3 styling (rounded corners, shadows, etc.)  Internet Explorer is one of the last browsers that doesn&#8217;t support it natively, either by browser specific hack or proper CSS3.</p>
<h3>Creating Rounded Corners</h3>
<p>Here is a quick demo to show how simple it is to implement the htc file.</p>
<h4>HTML</h4>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sampleBox&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></td></tr></tbody></table></div>
<h4>CSS</h4>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; .sampleBox<span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Initial Layout */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#014A8D</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*Rounded Corners for Firefox*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; -moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*Rounded Corners for Safari / Chrome*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; -webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*Standard CSS3*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*THE MAGIC...includes htc file for IE*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; behavior<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">PIE.htc</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6666ff;">.sampleBox</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* FF3.5 */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Saf3.0 , Chrome */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Opera 10.5, IE 9.0 */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Don't need to include PIE here because it's inherited.*/</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<div class="resources">
	 <a href="http://www.devirtuoso.com/Examples/CSS3-PIE/CSS3_PIE.zip"class="Download" target="_blank">Download</a>  <a href="http://www.devirtuoso.com/Examples/CSS3-PIE/"class="Example" target="_blank">Example</a>
</div>
<p>There is a bit of a delay as the script is run, so it&#8217;s not completely seamless.  Beggers can&#8217;t be choosers though.  Also one thing I noticed while working with it, your element needs to be a block element.  So if you&#8217;re have problems just throw up a display:block to fix any problems.  Otherwise a great tool.</p>
<p>For more examples visit <a href="http://css3pie.com/demos/tabs/" target="_blank">CSS3 PIE&#8217;s demo page</a></p>
<p>Be sure to check out the <a href="http://css3pie.com/" title="CSS3 PIE: CSS3 decorations for IE" target="_blank">main site</a> as well.</p>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2010/08/development-tool-css3-pie-for-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Way to Use Page Scrolling to Reveal an Image</title>
		<link>http://www.devirtuoso.com/2009/08/a-quick-way-to-use-page-scrolling-to-reveal-an-image/</link>
		<comments>http://www.devirtuoso.com/2009/08/a-quick-way-to-use-page-scrolling-to-reveal-an-image/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 14:33:46 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.devirtuoso.com/?p=886</guid>
		<description><![CDATA[From time to time you may see a website that reveals some image in the background when the user scrolls.  More times than not it displays advertising.  We’re going to create a super quick and easy web page that reveals an image as the user scrolls down. What We Are Building Here is a look [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time you may see a website that reveals some image in the background when the user scrolls.  More times than not it displays advertising.  We’re going to create a super quick and easy web page that reveals an image as the user scrolls down.</p>
<p><span id="more-886"></span></p>
<h2>What We Are Building</h2>
<p>Here is a look at what we’ll be building.  Not too fancy but it gets the job done.  It gives your site a nice little Easter egg for you users to find when surfing.</p>
<div class="resources"><a class="Download" href="http://www.devirtuoso.com/Examples/Scroll-Reveal/example.zip" target="_blank">Download</a><a class="Example" href="http://www.devirtuoso.com/Examples/Scroll-Reveal/" target="_blank">Example</a></div>
<p><a class="Example" href="http://www.devirtuoso.com/Examples/Scroll-Reveal/" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.devirtuoso.com/wp-content/uploads/2009/08/image19.png" border="0" alt="image" width="424" height="353" /></a></p>
<h2>Getting Started</h2>
<p>The first thing we’re going to have to do is image work.  Decide which image you want to reveal.  I just found a picture of a cat on the internet.  Second of all you’re going to have to create a fairly large image that goes from your background color to transparent.  It needs to be large enough to cover even your largest browser.  I made mine about 2000px square with a little texture in the gradation.  Once you have that made, simply save it as a transparent PNG and your ready to go.  The idea here is that the transparent PNG is going to sit on top of your hidden image.  Your PNG is going to scroll up,  but your hidden image is going to stay in place.  Kind of like the curtains at a theatre.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.devirtuoso.com/wp-content/uploads/2009/08/image20.png" border="0" alt="image" width="429" height="496" /></p>
<h2>The Code</h2>
<p>There is not much to this.  There is a single div wrapper which will have the PNG overlay as it’s background, and the body will have the hidden image as it’s background.  In this tutorial I also added some text and an arrow just to show that it is scrolling.</p>
<p>Just a couple of notes.  For this to work in IE6 your going to have to find a PNG transparency fix.  There are 10 million out there, just pick one.  I used the <a title="jquery pngfix plugin" href="http://jquery.andreaseberhard.de/pngFix/" target="_blank">jQuery pngFix plugin</a>. Also be sure to get rid of any margin padding on the body.  You’re PNG overlay won’t go to the edges if you have this margin in place.</p>
<p>Here is the Code:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span><br />
<span style="color: #00bbdd;">&nbsp; &nbsp; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>Page Title<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span>&gt;</span><br />
&nbsp; &nbsp; /* Get rid of any margins*/<br />
&nbsp; &nbsp; *{<br />
&nbsp; &nbsp; &nbsp; &nbsp; margin:0px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; padding:0px;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; /* Give the body your hidden image as the background<br />
&nbsp; &nbsp; and maked sure it is FIXED*/<br />
&nbsp; &nbsp; body{<br />
&nbsp; &nbsp; &nbsp; &nbsp; background: #000 url(1Fail.jpg) no-repeat fixed 50% bottom;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; /*Give the wrapper your overlay image as the background <br />
&nbsp; &nbsp; and make sure it SCROLLS*/<br />
&nbsp; &nbsp; #wrapper{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /* Just making sure you can scroll...probably will not need<br />
&nbsp; &nbsp; &nbsp; &nbsp; this if you have enough content */<br />
&nbsp; &nbsp; &nbsp; &nbsp; height:2000px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; width:100%;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; background: transparent url(overlay.png) no-repeat scroll left top;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; color:white;<br />
&nbsp; &nbsp; &nbsp; &nbsp; font-family: &nbsp;Arial, &quot;MS Trebuchet&quot;, sans-serif;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; /* Centering and styling text/image within the wrapper */<br />
&nbsp; &nbsp; #wrapper h1, #wrapper img{<br />
&nbsp; &nbsp; &nbsp; &nbsp; text-align:center;<br />
&nbsp; &nbsp; &nbsp; &nbsp; width:700px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; margin:0 auto;<br />
&nbsp; &nbsp; &nbsp; &nbsp; padding:100px 0px 0px;<br />
&nbsp; &nbsp; &nbsp; &nbsp; display:block;<br />
&nbsp; &nbsp; }<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!-- PNG FIX - NEEDED FOR IE6 &nbsp;--&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.pngFix.pack.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span> <br />
&nbsp; &nbsp; $(document).ready(function(){ <br />
&nbsp; &nbsp; &nbsp; &nbsp; $(document).pngFix(); <br />
&nbsp; &nbsp; }); <br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span> <br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Regular Content --&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span>Scroll Down to see the hidden image.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">h1</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">img</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;arrow.gif&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></td></tr></tbody></table></div>
<p>That’s all there is too it.  Nice and quick for a pretty cool effect.  Enjoy.</p>
<div class="resources"><a class="Download" href="http://www.devirtuoso.com/Examples/Scroll-Reveal/example.zip" target="_blank">Download</a><a class="Example" href="http://www.devirtuoso.com/Examples/Scroll-Reveal/" target="_blank">Example</a></div>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devirtuoso.com/2009/08/a-quick-way-to-use-page-scrolling-to-reveal-an-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.devirtuoso.com @ 2012-02-04 14:59:38 -->
