<?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>AddyOsmani.com &#124; Where Web Businesses Grow &#187; Under 10 Minutes</title>
	<atom:link href="http://addyosmani.com/blog/category/under-10-minutes/feed/" rel="self" type="application/rss+xml" />
	<link>http://addyosmani.com/blog</link>
	<description>This is the home of Addy Osmani (Web Developer, Designer &#38; Author). Here you can find some great tips and tutorials on everything to do with web development and even a few useful code samples!</description>
	<lastBuildDate>Sun, 25 Jul 2010 14:41:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How To Create A jQuery Plugin In Under 5 Minutes &#8211; A Helpful Screencast</title>
		<link>http://addyosmani.com/blog/jquery-plugin-in-under-5-minutes/</link>
		<comments>http://addyosmani.com/blog/jquery-plugin-in-under-5-minutes/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 00:52:24 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[author]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[how to create a jquery plugin]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery plugin tutorial]]></category>
		<category><![CDATA[jquery plugins]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[write a jquery plugin]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=948</guid>
		<description><![CDATA[Hey guys. As a follow up to HTML5 in Under 5 Minutes, in this week&#8217;s screencast I&#8217;m going to show you how to create a useful piece of jQuery code for making your own graphical tooltips and the I&#8217;m going to show you how to turn it into a fully customizable jQuery plugin. Click on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/jquerypluginin5mins/"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/howkoj.jpg" alt="" /></a></p>
<p>Hey guys. As a follow up to <a href="http://www.addyosmani.com/html5/">HTML5 in Under 5 Minutes</a>, in this week&#8217;s <a href="http://addyosmani.com/jquerypluginin5mins/">screencast</a> I&#8217;m going to show you how to create a useful piece of jQuery code for making your own graphical tooltips and the I&#8217;m going to show you how to turn it into a fully customizable jQuery plugin. Click on the <a href="http://addyosmani.com/jquerypluginin5mins/">preview</a> above to go to the dedicated micro-site for this screencast or <a href="http://addyosmani.com/jquerypluginin5mins/">here</a> to start watching it now. You can also download the sources from that page. I hope it helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/jquery-plugin-in-under-5-minutes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTML5 In 5 Minutes &#8211; A Screencast You Just Can&#8217;t Miss!</title>
		<link>http://addyosmani.com/blog/html5-in-5-minutes/</link>
		<comments>http://addyosmani.com/blog/html5-in-5-minutes/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 03:35:04 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[audio tag]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[geotagging]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 canvas]]></category>
		<category><![CDATA[html5 demos]]></category>
		<category><![CDATA[html5 sql]]></category>
		<category><![CDATA[html5 tutorial]]></category>
		<category><![CDATA[localstorage]]></category>
		<category><![CDATA[sessionstorage]]></category>
		<category><![CDATA[video element]]></category>
		<category><![CDATA[video tag]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=938</guid>
		<description><![CDATA[Hey guys. I recorded you a screencast on HTML5 over the weekend &#8211; I hope you like it!. It covers a lot of the core features HTML5 will bring including code samples for any material covered. Just click on the HTML5 thumbnail above to be taken to the HTML5 in under 5 minutes micro-site where [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/html5/"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/html5in5s.jpg" alt="" /></a></p>
<p>Hey guys. I recorded you a screencast on HTML5 over the weekend &#8211; I hope you like it!.  It covers a lot of the core features HTML5 will bring including code samples for any material covered. Just click  on the HTML5 thumbnail above to be taken to the HTML5 in under 5 minutes  micro-site where you can play or download the screencast. I hope it comes in useful! Thanks &#8211;  Addy.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/html5-in-5-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery &amp; CSS Sprite Animation Explained In Under 5 Minutes</title>
		<link>http://addyosmani.com/blog/jquery-sprite-animation/</link>
		<comments>http://addyosmani.com/blog/jquery-sprite-animation/#comments</comments>
		<pubDate>Mon, 31 May 2010 01:03:19 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[animated]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[css sprite animation]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[javascript sprite]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery sprite animation]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[spritely]]></category>
		<category><![CDATA[sprites]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=778</guid>
		<description><![CDATA[&#160; Today we&#8217;re going to take a look at sprite animation. There&#8217;s been a lot of talk this year about the future of technologies like Adobe&#8217;s Flash and for good reason &#8211; with the performance of JavaScript frameworks having come so far since they were first conceived, it&#8217;s now possible to create equally as powerful [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/jquery-sprite-animation/"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/csssp.jpg" alt="" /></a></p>
<p>&nbsp;</p>
<p>Today we&#8217;re going to take a look at sprite animation. There&#8217;s been a lot of talk this year about the future of technologies like Adobe&#8217;s Flash and for good reason &#8211; with the performance of JavaScript frameworks having come so far since they were first conceived, it&#8217;s now possible to create equally as powerful animations and effects without needing to use any third party plugins.In today&#8217;s screencast I&#8217;m going to show you what a sprite is and just how easy it can be to create an entire animated scene using jQuery, CSS &amp; Sprites. You&#8217;ll also get to see some pretty cool out-in-the-wild examples of jQuery Sprite Animation in action, so why not check it out in my screencast below!</p>
<p><span id="more-778"></span></p>
<p>&nbsp;</p>
<p><object width="500" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="http://screenr.com/Content/assets/screenr_1116090935.swf" name="movie" /><param value="i=67218" name="flashvars" /><param value="true" name="allowFullScreen" /><embed width="500" height="345" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" flashvars="i=67218" src="http://screenr.com/Content/assets/screenr_1116090935.swf"></embed></object></p>
<p>Demos and text are available for anyone that wants to read/see them in the rest of the post.</p>
<p>&nbsp;</p>
<p><a href="http://www.addyosmani.com/resources/sprites/demo.html" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank"> View Demo</a> &nbsp;<a href="http://www.addyosmani.com/resources/sprites/spritesin5mins.zip" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank">Download Source</a></p>
<p>&nbsp;</p>
<p><img width="500" border="0" src="http://www.addyosmani.com/images/gopher.jpg" alt="" /></p>
<p>&nbsp;</p>
<p>Today&#8217;s animations are created using a really useful jQuery plugin called Spritely. You can download the Spritely plugin <a href="http://spritely.net/download/">here</a>. Spritely allows you to create your own animations using two simple functions.The pan() function which lets you pan (move) an image across the screen in a particular direction; and the sprite() function which lets you work with multiple frames and add more complex behaviours to your animations. In the screencast I show you how to first use pan() to create a moving silhouette of a city and then we use the sprite() function to add an animated plane to it. To help you with your own creations, I&#8217;m including code for both of these below.</p>
<p>&nbsp;</p>
<h2>Basic Example using Pan()</h2>
<p>&nbsp;</p>
<p>How complex your animations can get really depend on what you&#8217;re trying to achieve. If you&#8217;re trying to create a moving landscape scene, you&#8217;ll probably be able to knock that out fairly quickly because all you need to do is pan your images across the screen at a particular speed.</p>
<p><img width="500" border="0" src="http://www.addyosmani.com/images/citymove.jpg" alt="" /></p>
<p>Here&#8217;s the sample code I used to create the city skyline panning effect:</p>
<p>&nbsp;</p>
<p><strong>The jQuery</strong></p>
<pre class="javascript" name="code">
			$(document).ready(function() {
				$('#city').pan({fps: 30, speed: 2, dir: 'left'});
				});
</pre>
<p>&nbsp;</p>
<p><strong>The HTML</strong></p>
<pre class="html" name="code">
<div id="city">&nbsp;</div>
</pre>
<p>&nbsp;</p>
<p><strong>The CSS</strong></p>
<pre class="css" name="code">
		body {
			background: #fff;
			margin:0 auto;
		}

		/*City Silhouette*/
		#city {
			position: absolute;
			width: 99%;
			height: 416px;
			background: transparent url(city.png) 0 130px repeat-x;
			border: 1px solid black;
		}
</pre>
<p>&nbsp;</p>
<h2>Advanced Example Using Pan() &amp; Sprite()</h2>
<p>&nbsp;</p>
<p>If however you&#8217;d like to create something a little more detailed like a 2D or 3D character with movement, you&#8217;ll need to use a package like Maya, 3DMax or even Flash to output the animation as frames with a transparent background. Next, follow my steps below to create the jQuery animation for it.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<ol>
<li>Output your frames as transparent PNG files to a directory on your drive. Because animation can sometimes be a memory intensive task, you&#8217;ll want to minimize this as much as possible. This can be achieved by outputting 1 frame for every 5-15 in your original animation. Don&#8217;t worry! The Spritely plugin supports setting custom frame-rates so you can still make your final animation look relatively smooth.</li>
<li>Use a Sprite Generation tool such as <a href="http://css-sprit.es">CSSSprit.es</a> or <a href="http://csssprites.com/">CSSSprites.com</a> to stitch your frames together as a single image file. Try to keep the final filesize down to within a few megabytes (I would say 2MB should really be the higher end of that filesize).</li>
<li>Next animate your content using Spritely as I did in my demo. You can find some sample code for this below.</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img width="500" border="0" src="http://www.addyosmani.com/images/skyline.jpg" alt="" /></p>
<p><strong>The jQuery</strong></p>
<pre class="javascript" name="code">
  (function($) {
			$(document).ready(function() {

			    /* City 1 */
				$('#city1').pan({fps: 30, speed: 1, dir: 'right'}); 

				/* City 2 - This gives the animation a depth of perspective
				as one city silhoette is slightly away from the other*/
				$('#city2').pan({fps: 30, speed: 2, dir: 'right'}); 

				/*The clouds and sky*/
				$('#sky').pan({fps: 30, speed: 0.5, dir: 'right'}); 

				/*The Plane animation*/
				var stage_left = (($('body').width() - 866) / 2);
				var stage_top = 30;

				/* Spritely's sprite function allows you to define
				more complex animations which contain more than 1
				frame. You can also use the spRandom feature to define
				random behaviour.
				*/
				$('#plane1').sprite({fps: 8, no_of_frames: 14})
					.spRandom({
						top: 40,
						left: stage_left + 20,
						right: 400,
						bottom: 140,
						speed: 3500,
						pause: 1000
					});

			});
		})(jQuery);
  </pre>
<p>&nbsp;</p>
<p><strong>The HTML</strong></p>
<pre class="html" name="code">
<div id="sky">&nbsp;</div>
<div id="city1">&nbsp;</div>
<div id="city2">&nbsp;</div>
<div id="plane1">&nbsp;</div>
<div id="content">
<div id="leftcontent">
<div id="rightcontent">&nbsp;</div>
</div>
</div>
</pre>
<p>&nbsp;</p>
<p><strong>The CSS</strong></p>
<pre class="css" name="code">
			body
			{
			background: #fff;
			margin:0 auto;
		     }

		#sky {
		  position:absolute;
		  width:100%;
		  height: 416px;
		  background: transparent url(sky.jpg) 0 0px repeat-x; 

		}

		#city {
			position: absolute;
			width: 100%;
			height: 416px;
			background: transparent url(city.png) 0 130px repeat-x;

		}

		#city2 {
			position: absolute;
			width: 100%;
			height: 416px;
			background: transparent url(city2.png) 0 130px repeat-x;
		}

		#plane1 {
			position: absolute;
			width: 730px;
			height: 167px;
			background: transparent url(planesprite.png) 0 50px no-repeat;
		}

		#content {

		   width: 100%;
		   position:relative;
		   clear:both;
		}

		#leftcontent {
		  width:70%;
		}

		#rightcontent {
		  width:30%;
		  background-color:blue;
		}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>And thats it!. As with all my &#8216;Under 5 Minutes&#8217; series, you obviously won&#8217;t have learned absolutely everything there is to know about sprite animation, but hopefully you will have picked up many of the basics. Please feel free to download the source files and play around with them &#8211; I hope they come in useful!</p>
<p>&nbsp;</p>
<h2>Demo &amp; Download</h2>
<p>&nbsp;</p>
<p><a href="http://www.addyosmani.com/resources/sprites/demo.html" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank"> View Demo</a> &nbsp;<a href="http://www.addyosmani.com/resources/sprites/spritesin5mins.zip" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank">Download Source</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>&nbsp;</p>
<p>This tutorial was created to demonstrate how to create animations in jQuery using sprites. This powerful technique is a simple, effective way of creating cross-browser friendly animations that don&#8217;t need to rely on Flash or any third-party plugins to function. To see more demos of how Spritely is being used to add rich animated experiences to web pages, feel free to have a look at the Spritely gallery <a href="http://spritely.net/gallery/">here</a>. If you enjoyed today&#8217;s post, please share it with your friends and colleagues by clicking <a href="http://addyosmani.com/blog/jquery-sprite-animation/" class="retweet">jQuery &amp; CSS Sprite Animation Explained In Under 5 Minutes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/jquery-sprite-animation/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Fluid Navigation &#8211; How to create an informative menu-bar with jQuery &amp; CSS</title>
		<link>http://addyosmani.com/blog/fluid-navigation-how-to-create-an-informative-menu-bar-with-jquery-in-just-a-few-minutes/</link>
		<comments>http://addyosmani.com/blog/fluid-navigation-how-to-create-an-informative-menu-bar-with-jquery-in-just-a-few-minutes/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 22:03:31 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[creative menu]]></category>
		<category><![CDATA[fluid navigation]]></category>
		<category><![CDATA[javascript menus]]></category>
		<category><![CDATA[javasript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery creative menu]]></category>
		<category><![CDATA[jquery drop down]]></category>
		<category><![CDATA[jquery drop-down navigation]]></category>
		<category><![CDATA[jquery information]]></category>
		<category><![CDATA[jquery informative menu]]></category>
		<category><![CDATA[jquery menu]]></category>
		<category><![CDATA[jquery menus]]></category>
		<category><![CDATA[jquery navigating]]></category>
		<category><![CDATA[jquery navigation tutorial]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/fluid-navigation-how-to-create-an-informative-menu-bar-with-jquery-in-just-a-few-minutes/</guid>
		<description><![CDATA[&#160; &#160; After a few weeks away in the US, I&#8217;m back with a brand new jQuery post &#8211; this week taking a look at a new style of navigation menu. jQuery has made it simple for developers to define an idea or wireframe for a component and then implement it reasonably quickly, which has [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<a href="http://addyosmani.com/blog/fluid-navigation-how-to-create-an-informative-menu-bar-with-jquery-in-just-a-few-minutes/#myPosts"><img border="0" src="http://addyosmani.com/blog/wp-content/uploads/fluia.jpg" alt="fluia" style="border: 0px none ; display: inline;" title="fluia" /></a></p>
<p>&nbsp;</p>
<p>After a few weeks away in the US, I&rsquo;m back with a brand new jQuery post &ndash; this week taking a look at a new style of <a href="http://addyosmani.com/resources/fluid-menu/fluid-menu.html">navigation menu</a>. jQuery has made it simple for developers to define an idea or wireframe for a component and then implement it reasonably quickly, which has certainly helped it become the most popular JavaScript Framework out there at the moment. I feel like some of the navigation options out there right now don&rsquo;t provide you with enough information about the sections of a site you can visit, so today we&rsquo;re going to learn how to create a menu that solves this problem.&nbsp;</p>
<p>&nbsp;</p>
<p><span id="more-394"></span></p>
<p><a href="http://addyosmani.com/resources/fluid-menu/fluid-menu.html">Here&rsquo;s</a> what we&rsquo;re going to be creating in it&rsquo;s final form.</p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/resources/fluid-menu/fluid-menu.html"><img width="550" height="298" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image.png" alt="image" style="border: 0px none ; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>First, I&rsquo;m going to define what the menu can do and we&rsquo;ll take a look at a rough wireframe I created using <a href="http://www.mockflow.com">MockFlow</a>&rsquo;s free wireframe generator. We want to create a menu that appears like a standard menu bar in it&rsquo;s default state, but which on rollover pulls down an information area that covers both the original menubar item and has an expanded section containing the text we want to display. This can be seen in the wireframe below.</p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/02/Fluid_Menu.png" class="thickbox"><img width="541" height="219" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/Fluid_Menu_thumb.png" alt="Fluid_Menu" style="border: 0px none ; display: block; float: none; margin-left: auto; margin-right: auto;" title="Fluid_Menu" /></a></p>
<p>&nbsp;</p>
<p>Next, let&rsquo;s begin to create this menu using some basic HTML structure and CSS. We&rsquo;re going to need a holder for the menu, the menu itself, each item and a div for each of the drop-down elements we&rsquo;re going to display information in.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuBarHolder&quot;</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuBar&quot;</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;firstchild&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the home section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Services<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the services section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Clients<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the clients section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Portfolio<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the portfolio section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>About<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the about section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Blog<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the blog section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Follow<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the follow section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript:#&quot;</span>&gt;</span>Contact<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuInfo&quot;</span>&gt;</span>I am some text about the contact section<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<p>We&rsquo;re now going to style this content. Because we only want to display the extra information for each section when a user hovers over an &ldquo;li&rdquo; element, we&rsquo;re going to hide the information divs until they&rsquo;re needed. I&rsquo;ve also noticed that a lot of the popular browsers you guys use (IE aside) support CSS rounded corners, so I&rsquo;m including this effect to be used for the drop-down menus &#8211; it&rsquo;s visually more pleasing to the eye than corners in some designs, and if you&rsquo;d prefer you can drop the last few terms in the &ldquo;menuInfo&rdquo; class.</p>
<p>&nbsp;</p>
<p>This menu is completely cross-browser compatible (yay!) so it&rsquo;s possible to use rounded corner definitions without needing to worry about how they&rsquo;ll render in older browsers &ndash; everything should gracefully degrade as per necessary.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&nbsp;
<span style="color: #cc00cc;">#menuBarHolder</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">730px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <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> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#menuBarHolder</span> ul<span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <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><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#menuBar</span> li<span style="color: #00AA00;">&#123;</span>  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#menuBar</span> li a<span style="color: #00AA00;">&#123;</span><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> <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> <span style="color: #000000; font-weight: bold;">letter-spacing</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.menuHover</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.firstchild</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.menuInfo</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span>hand<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <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>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">74px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span>height<span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <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> <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>
<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> <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-15px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-15px</span><span style="color: #00AA00;">;</span>
-moz-border-radius-bottomright<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
-moz-border-radius-bottomleft<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
-webkit-border-bottom-left-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
-webkit-border-bottom-right-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
-khtml-border-radius-bottomright<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
-khtml-border-radius-bottomleft<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
 border-radius-bottomright<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
border-radius-bottomleft<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p style="text-align: center;"><img width="459" height="229" alt="" src="http://addyosmani.com/blog/wp-content/uploads/menus.jpg" /></p>
<p>Finally, let&rsquo;s take a look at the jQuery for our Fluid Menu. We want to add hover cases to each element of our menu so that when a user moves their mouse over a menu-item, the information div animates into place elegantly. To achieve this, we&rsquo;re simply going to use jQuery&rsquo;s built-in slideDown and slideUp effects as they provide the most efficient way to achieve the effect we want with the least amount of code.</p>
<p>&nbsp;</p>
<p>We also want users to be able to click on the entire &ldquo;li&rdquo; element rather than the links inside them, so we&rsquo;re going to bind a pseduo-click event to all the menu&rsquo;s li&rsquo;s by means of document.location.href and an attribute check on the href of their child links.This is achieved as follows:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<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>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#menuBar li'</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><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> url <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;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  document.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> url<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#menuBar li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</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>
   $<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;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.menuInfo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<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;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.menuInfo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;</p>
<p>and that&rsquo;s it!. You can now easily set additional information for any of the menu items in your menu-bar and if needed you can easily extend the length of the drop-downs to suit your needs. You can find a demo and download links to all of the code in today&rsquo;s post below.</p>
<p>&nbsp;</p>
<p><strong>Demo:</strong> <a href="http://addyosmani.com/resources/fluid-menu/fluid-menu.html">http://addyosmani.com/resources/fluid-menu/fluid-menu.html</a></p>
<p><strong>Download:</strong> <a href="http://addyosmani.com/resources/fluid-menu/fluid-menu.zip">http://addyosmani.com/resources/fluid-menu/fluid-menu.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/fluid-navigation-how-to-create-an-informative-menu-bar-with-jquery-in-just-a-few-minutes/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>How to Create A JavaScript Carousel From Scratch In Under 10 Minutes</title>
		<link>http://addyosmani.com/blog/how-to-create-a-javascript-carousel-from-scratch-in-under-10-minutes/</link>
		<comments>http://addyosmani.com/blog/how-to-create-a-javascript-carousel-from-scratch-in-under-10-minutes/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 04:22:18 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Carousel]]></category>
		<category><![CDATA[carousel tutorial]]></category>
		<category><![CDATA[carousel ui]]></category>
		<category><![CDATA[create carousel]]></category>
		<category><![CDATA[image gallery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript carousel]]></category>
		<category><![CDATA[javascript carousel ui]]></category>
		<category><![CDATA[javascript carousels]]></category>
		<category><![CDATA[javascript image gallery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/how-to-create-a-javascript-carousel-from-scratch-in-under-10-minutes/</guid>
		<description><![CDATA[Hi everyone and welcome to part 2 of my &#34;Learn in 10 Minutes&#34; series. Last week I showed you how to learn everything about CSS Sprites and this week I thought we&#8217;d take a look at some JavaScript. In this article you&#8217;ll learn how to create your very own JavaScript Carousel from scratch in under [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone and welcome to part 2 of my &quot;Learn in 10 Minutes&quot; series. Last week I showed you how to learn everything about <a href="http://blarnee.blogspot.com/2009/09/css-sprites-in-under-10-minutes.html">CSS Sprites</a> and this week I thought we&#8217;d take a look at some JavaScript. In this article you&#8217;ll learn how to create your very own JavaScript Carousel from scratch in under 10 minutes so without further delay, let&#8217;s <a href="http://www.scribd.com/doc/19581128/How-to-Create-A-JavaScript-Carousel-From-Scratch-In-Under-10-Minutes">begin</a>!<span id="more-40"></span><a title="(Enlarge) View How to Create A JavaScript Carousel From Scratch In Under 10 Minutes on Scribd" style="display: block; margin: 12px auto 6px; font: 14px helvetica,arial,sans-serif; text-decoration: underline; -x-system-font: none; font-size-adjust: none; font-stretch: normal" href="http://www.scribd.com/doc/19581128/How-to-Create-A-JavaScript-Carousel-From-Scratch-In-Under-10-Minutes">(Enlarge) How to Create A JavaScript Carousel From Scratch In Under 10 Minutes</a> <object align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" height="500" id="doc_953030479263714" name="doc_953030479263714" width="450"><param name="movie" value="http://d1.scribdassets.com/ScribdViewer.swf?document_id=19581128&amp;access_key=key-2lee7bkdg0cr63xh9kwl&amp;page=1&amp;version=1&amp;viewMode=slideshow"><param name="quality" value="high"><param name="play" value="true"><param name="loop" value="true"><param name="scale" value="showall"><param name="wmode" value="opaque"><param name="devicefont" value="false"><param name="bgcolor" value="#ffffff"><param name="menu" value="true"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><param name="salign" value=""><param name="mode" value="slideshow"><embed src="http://d1.scribdassets.com/ScribdViewer.swf?document_id=19581128&amp;access_key=key-2lee7bkdg0cr63xh9kwl&amp;page=1&amp;version=1&amp;viewMode=slideshow" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_953030479263714_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" mode="slideshow" height="500" width="450"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/how-to-create-a-javascript-carousel-from-scratch-in-under-10-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Sprites in Under 10 Minutes</title>
		<link>http://addyosmani.com/blog/css-sprites-in-under-10-minutes/</link>
		<comments>http://addyosmani.com/blog/css-sprites-in-under-10-minutes/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 04:20:22 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[animation examples]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css examples]]></category>
		<category><![CDATA[css sprite examples]]></category>
		<category><![CDATA[css sprites]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/css-sprites-in-under-10-minutes/</guid>
		<description><![CDATA[In this post I&#8217;m going to teach you everything you need to know about CSS Sprites in under 10 minutes &#8211; you&#8217;ll learn a little the basics of what they can do..and more importantly, how you can implement them in your projects. So, lets start!. So..what is a Sprite? Back in 2004, a guy called [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;m going to teach you everything you need to know about CSS Sprites in under 10 minutes &#8211; you&#8217;ll learn a little the basics of what they can do..and more importantly, how you can implement them in your projects. So, lets start!.</p>
<p> <span id="more-38"></span></div>
<p> 
<p><b>So..what <i>is</i> a Sprite?</b></p>
<p>Back in 2004, a guy called Dave Shea came up with a simple CSS-based approach to using multiple-images across a website and combining them into a single <i>master image</i>. His concept was quite straight-forward -&#160; to show a single image from the master image you would use the background-position property in CSS to define the exact position of the image to display. It was versatile enough that you could use hover, active or focus effects using the same background-position property for any element displayed.&#160; </p>
<p>&#160;</p>
<p><b>Why should I use them? It&#8217;s easier to just slice my images separately, right?</b></p>
<p>CSS Sprites have a lot of different advantages. The first is that your users only need to download a single image file for the graphics on your page (and thus it can complete loading much quicker). Secondly, if you need to update any of the graphics on your page, you only need to release a single image file live to have the chances come into effect. Need to optimize all your images? A master image just requires one round of optimization so you effectively cut down your work exponentially.</p>
<p>&#160;</p>
<p><b>Before I learn how to use these Sprite things..who else is using them?</b></p>
<p>Everybody. Apple.com, Amazon, YouTube, CNN and even Digg.com use CSS Sprites for their graphics. There&#8217;s even a <a href="http://spritegen.website-performance.org/">website </a>that helps you generate your own Sprites by uploading your image to their server.</p>
<p>&#160;</p>
<p><a href="http://media1.smashingmagazine.com/images/css-sprites/apple.jpg"><img height="108" src="http://addyosmani.googlepages.com/apple.jpg" width="420" border="0" /></a></p>
<p><b></b></p>
<p><b>Okay..so how are they done?</b></p>
<p>Lets take the example of a horizontal navigation menu. Normally you would do something like this to set each of the background images for your menu items:</p>
<p>&#160;</p>
<p><font color="#ff0000">#nav li a {background:none no-repeat left center} </font></p>
<p><font color="#ff0000">#nav li a.item1 {background-image:url(&#8216;../img/image1.gif&#8217;)} </font></p>
<p><font color="#ff0000">#nav li a:hover.item1 {background-image:url(&#8216;../img/image1_over.gif&#8217;)} </font></p>
<p><font color="#ff0000">#nav li a.item2 {background-image:url(&#8216;../img/image2.gif&#8217;)} </font></p>
<p><font color="#ff0000">#nav li a:hover.item2 {background-image:url(&#8216;../img/image2_over.gif&#8217;)}</font></p>
<p>&#160;</p>
<p>For 10 different images that&#8217;s a whole 10 different HTTP requests that need to be made. We&#8217;re talking about what.. 20-40kb in total that your page needs to load up (just for the graphics?)&#160; We can do better than that..</p>
<p>If instead you use a &quot;master&quot; image to store all your menu backgrounds, it&#8217;s as easy as pie to use background-positioning to access the same images:</p>
<p>&#160;</p>
<p><font color="#ff0000">#nav li a {background-image:url(&#8216;../img/image_nav.gif&#8217;)} </font></p>
<p><font color="#ff0000">#nav li a.item1 {background-position:0px 0px} </font></p>
<p><font color="#ff0000">#nav li a:hover.item1 {background-position:0px -72px} </font></p>
<p><font color="#ff0000">#nav li a.item2 {background-position:0px -143px;} </font></p>
<p><font color="#ff0000">#nav li a:hover.item2 {background-position:0px -215px;}</font></p>
<p>&#160;</p>
<p>That means your page just needs to perform 1 HTTP request to grab all your image and it only takes up 15-18kb as you&#8217;re not using multiple files with their own image headers.</p>
<p>&#160;</p>
<p>Here&#8217;s another quick and dirty example:</p>
<p><a href="http://www.ignacioricci.com/tutorials/sprites/images/guideImgs/background-position.png"><img height="177" src="http://www.ignacioricci.com/tutorials/sprites/images/guideImgs/background-position.png" width="420" border="0" /></a></p>
<p>Here&#8217;s a master image which contains some pretty cool vector characters. I would like to use the third one, so using PhotoShop, Fireworks or my favourite image editor, I find out how far away the image is from the left and how far it is from the top. As you can see this is -196x and -2px. The image is 115px in width. Accessing the image is thenas simple as doing the following:</p>
<p>&#160;</p>
<p><font color="#ff0000">.sprite {background:url(sprite.png);}&#160; </font></p>
<p><font color="#ff0000">.thirdimage {width:115px; background-position:-196px -2px;}</font></p>
<p>&#160;</p>
<p>And that&#8217;s it!. If I&#8217;ve successfully convinced you that CSS Sprites are the way forward, </p>
<p>click <a href="http://www.itnewb.com/v/Optimize-Your-Web-Site-by-Using-CSS-Image-Sprites">here </a>to learn how to get the positions of the images in your &quot;master&quot; so you can start </p>
<p>making your own or check out the CSS Sprite generator <a href="http://spritegen.website-performance.org/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/css-sprites-in-under-10-minutes/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
