<?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>Design Shack &#187; JavaScript</title>
	<atom:link href="http://designshack.net/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://designshack.net</link>
	<description>Inspiration, CSS Gallery &#38; Community News</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Three Super Easy Ways to Pull Off a Masonry Layout</title>
		<link>http://designshack.net/articles/css/masonry/</link>
		<comments>http://designshack.net/articles/css/masonry/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 06:00:30 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[masonry]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=29284</guid>
		<description><![CDATA[Masonry style layouts push the boundaries of creative layout techniques. I personally love how capable they prove to be at maximizing the efficiency of galleries containing items with varying heights. Every bit of screen space is used and the result can be downright mesmerizing. Today we&#8217;re going to dive into the concept, ideas and popular [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-0.jpg" alt="screenshot" width="510"/></div>
<p>Masonry style layouts push the boundaries of creative layout techniques. I personally love how capable they prove to be at maximizing the efficiency of galleries containing  items with varying heights. Every bit of screen space is used and the result can be downright mesmerizing.</p>
<p>Today we&#8217;re going to dive into the concept, ideas and popular techniques that are currently prevalent in masonry style layouts. We&#8217;ll learn three different methods for pulling off a masonry layout, discuss the ins and outs of each and make sure that the result is beautifully responsive and reflows based on browser width. </p>
<p><span id="more-29284"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>What Is a Masonry Layout?</h2>
<p>When you float objects in CSS, the browser arranges elements first horizontally then vertically. When we fill a container with a bunch of equally sized objects and float them left, we get a nice grid of images.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-2.jpg" alt="screenshot" width="510"/></div>
<p>However, if the objects have variable heights, the results are much more difficult to predict. Instead of a nice tight grid, we get something that tends to be fairly scattered. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-1.jpg" alt="screenshot" width="510"/></div>
<p>The obvious quandary here is how to pull off a nice tight grid that with items that have variable heights. It&#8217;s a pretty interesting topic and various developers have come up with several ways to go about it. Let&#8217;s take a look at three of the current best solutions. </p>
<p>To go one step further, we&#8217;re going to make sure that all three solutions are responsive, meaning the grid will reflow as the window size changes. </p>
<h2>jQuery Masonry</h2>
<div class="tutorialimage"><a href="http://masonry.desandro.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-6.jpg" alt="screenshot" width="510"/></a></div>
<p><a href="http://masonry.desandro.com/index.html">jQuery Masonry</a> is the most popular solution to pull off this type of layout. It utilizes some pretty fancy JavaScript to reflow a series of divs. </p>
<p>Putting Masonry into practice is pretty easy, all you need is a container that holds a series of divs that you want to arrange masonry style. You can place anything you want inside the divs, in this case I threw in some placeholder images.</p>
<p>Once you have that in order, toss in jQuery and jQuery Masonry. Then you need to create a simple function that identifies your container and targets the class that we used for our Masonry images divs. Here&#8217;s a basic example:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div 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;container&quot;</span>&gt;</span>
	<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;masonryImage&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/200/food/1&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>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</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;masonryImage&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/150/food/10&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>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</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;masonryImage&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/250/food/3&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>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
	. . .
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.7.1.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.masonry.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  $(function(){
&nbsp;
    var $container = $('#container');
&nbsp;
    $container.imagesLoaded( function(){
      $container.masonry({
        itemSelector : '.masonryImage'
      });
    });
&nbsp;
  });
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<h3>CSS</h3>
<p>As long as we have a width set on our container div, the code above performs the magic we need it to and reflows the elements. If you set the div width to a percent, jQuery Masonry even automatically reflows the items as the page resizes.</p>
<p>Even though this is the case, things can get messy if you want to keep your container centered. I found it easier to apply a static width to my container, then use media queries to reflow the columns as the page size decreases past the container size. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#container</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;">1200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Media Queries*/</span>
<span style="color: #a1a100;">@media only screen and (max-width : 1199px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">1199px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#container</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;">1000px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 999px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">999px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#container</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;">800px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 799px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">799px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#container</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;">600px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 599px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">599px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#container</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;">400px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 399px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">399px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#container</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;">200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>See It In Action</h3>
<p>This gives us a nice tight image gallery that perfectly responds to various browser window sizes. I&#8217;ve taken all the spacing out to illustrate just how tight you can get your images, but feel free to build in some margins so your images are spaced out a bit more. </p>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/masonry/demos/masonry.html">Click here</a> to launch demo</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-3.jpg" alt="screenshot" width="510"/></div>
<h2>Wookmark</h2>
<div class="tutorialimage"><a href="http://www.wookmark.com/jquery-plugin"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-7.jpg" alt="screenshot" width="510"/></a></div>
<p>Another popular JavaScript solution for achieving the same type of layout is <a href="http://www.wookmark.com/jquery-plugin">Wookmark.js</a>, which is the driving plugin behind the Pinterest-like <a href="http://www.wookmark.com/">Wookmark.com</a>.</p>
<p>Wookmark.js is in my opinion a little trickier to implement than jQuery Masonry because of the lack of documentation, but it&#8217;s still pretty basic stuff. All we need to do to start is toss a bunch of images into an unordered list. The catch with this plugin is that we have to declare inline height values for each of the images.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><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;myContent&quot;</span>&gt;</span> 			
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;height: 206px;&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/206/animals/1&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;&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> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;height: 256px;&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/256/animals/2&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;&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> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;height: 216px;&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/216/animals/3&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;&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> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;height: 276px;&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/276/animals/4&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;&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: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>Once you&#8217;ve got that set up, then you insert the JavaScript at the bottom of the body just like last time. Insert both jQuery and Wookmark.js, then set up the simple function below, which targets the list items in our #myContent unordered list.</p>
<p>I tossed in another simple function here which essentially reloads the script as the window changes size. This will ensure that the columns automatically reflow and provide that responsive functionality. This time around we&#8217;ll ditch the media queries and let the JavaScript handle all of the layout.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.7.1.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.wookmark.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
		$('#myContent li').wookmark({offset: 2});
&nbsp;
		window.onresize = function(event) {
		    $('#myContent li').wookmark({offset: 2});
		}
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<h3>CSS</h3>
<p>The CSS for this version is super minimal. All we need to do is set our ul width with a percentage and use position:relative. Then we set a specific width for each list item. That&#8217;s it!</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#myContent</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;">80%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#myContent</span> li <span style="color: #00AA00;">&#123;</span>
	<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>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>See It In Action</h3>
<p>Just like last time, the result is a tight grid of images. However, even though spacing options are adjustable with Wookmark.js, I couldn&#8217;t get it to work at zero so we have a little bit of spacing in between the images. </p>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/masonry/demos/wookmark.html">Click here</a> to launch demo</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-4.jpg" alt="screenshot" width="510"/></div>
<h2>Pure CSS</h2>
<p>The JavaScript solutions are probably the safest and most widely compatible ways to go about a masonry layout, but the CSS nerd in me knew there had to be a way to pull it off without JavaScript.</p>
<p>It turns out, it&#8217;s actually pretty easy using some fancy CSS3. This technique was pioneered by <a href="http://sickdesigner.com/index.php/2011/html-css/masonry-css-getting-awesome-with-css3/">Radu Chelariu at SickDesigner</a> and though it&#8217;s definitely not as powerful, flexible, or cross-browser-compatible as the previous options, it&#8217;s still extremely impressive given that it&#8217;s all CSS.</p>
<p>To start off, let&#8217;s use the same unordered list that we did last time (no inline styles necessary), thrown into a container div. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div 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;container&quot;</span>&gt;</span>
	<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;myContent&quot;</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;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/206/nature/1&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;&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;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/256/nature/2&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;&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;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/216/nature/3&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;&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;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.co.uk/wp-content/uploads/http://lorempixum.com/200/276/nature/4&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;&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: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</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></div></div>

</div>
<p></ br></p>
<h3>CSS</h3>
<p>Here&#8217;s where the voodoo happens. To start, apply a width to the container and center it. Then use the new CSS columns functionality to lay out the content into six columns with zero gap. Finally, target the images directly and set the display to inline-block with a width of 100%. Inline-block allows us to flow elements inline without floats while maintaining block level functionality. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#container</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;">1200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#myContent</span> <span style="color: #00AA00;">&#123;</span>
	-moz-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">6</span><span style="color: #00AA00;">;</span>
	-moz-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	-webkit-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">6</span><span style="color: #00AA00;">;</span>
	-webkit-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">6</span><span style="color: #00AA00;">;</span>
	column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#myContent</span> img<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>That&#8217;s all we need for the masonry layout, but we still have the responsive bit to go. We&#8217;ll basically use the same trick that we used for the first layout, only this time we&#8217;ll change the column count and container width when the window size gets too narrow. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media only screen and (max-width : 1199px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">1199px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#myContent</span> <span style="color: #00AA00;">&#123;</span>
		-moz-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">5</span><span style="color: #00AA00;">;</span>
		-moz-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		-webkit-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">5</span><span style="color: #00AA00;">;</span>
		-webkit-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">5</span><span style="color: #00AA00;">;</span>
		column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#container</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;">1000px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 999px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">999px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#myContent</span> <span style="color: #00AA00;">&#123;</span>
		-moz-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">4</span><span style="color: #00AA00;">;</span>
		-moz-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		-webkit-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">4</span><span style="color: #00AA00;">;</span>
		-webkit-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">4</span><span style="color: #00AA00;">;</span>
		column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#container</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;">800px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 799px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">799px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#myContent</span> <span style="color: #00AA00;">&#123;</span>
		-moz-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span>
		-moz-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		-webkit-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span>
		-webkit-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">34</span><span style="color: #00AA00;">;</span>
		column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#container</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;">600px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media only screen and (max-width : 599px),</span>
only screen and <span style="color: #00AA00;">&#40;</span>max-device-<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">599px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #cc00cc;">#myContent</span> <span style="color: #00AA00;">&#123;</span>
		-moz-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
		-moz-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		-webkit-column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
		-webkit-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		column-count<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
		column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#container</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;">400px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Compatibility</h3>
<p>The big problem here is that IE doesn&#8217;t have support for CSS columns until IE10. This means that you&#8217;ll have to use jQuery Masonry as a backup for IE users if you want to implement this technique in a real world scenario. </p>
<h3>See It In Action</h3>
<p>Here&#8217;s our third and final masonry layout demo. At a glance, the effect is exactly like we saw with jQuery Masonry. Not bad for plain old CSS!</p>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/masonry/demos/css.html">Click here</a> to launch demo</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/masonry-layout-5.jpg" alt="screenshot" width="510"/></div>
<h2>Conclusion</h2>
<p>In a <a href="http://designshack.net/articles/business-articles/addictive-ux-why-pinterest-is-so-dang-amazing/">recent article on Pinterest</a>, I discussed just how powerful masonry layouts can be from a UX perspective, especially when combined with infinite scrolling.</p>
<p>You can definitely expect this budding trend to increase in popularity and before you know it you&#8217;ll have clients asking for a layout like the one they see on Pinterest. When this happens, you&#8217;ll now be prepared with not one but three possible solutions!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/masonry/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A Designer&#8217;s Introduction to Programming</title>
		<link>http://designshack.net/articles/javascript/an-designers-introduction-to-programming/</link>
		<comments>http://designshack.net/articles/javascript/an-designers-introduction-to-programming/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 19:13:15 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=26023</guid>
		<description><![CDATA[Designers are often quite hesitant to venture beyond the realms of HTML and CSS into the territory of scripting and programming languages, and for good reason. Programming requires a very different set of skills than mocking up web pages. Further, there are so many different things to learn that most designers don&#8217;t even know where [...]]]></description>
			<content:encoded><![CDATA[<p>Designers are often quite hesitant to venture beyond the realms of HTML and CSS into the territory of scripting and programming languages, and for good reason. Programming requires a very different set of skills than mocking up web pages. Further, there are so many different things to learn that most designers don&#8217;t even know where to begin: JavaScript, PHP, Ruby, Rails, how can you possibly keep up? </p>
<p>However, in practice, programming turns out to be much less scary than designers imagine it to be. Today I&#8217;m going to show you how programming is a skill that you can learn once and then apply to each new language that you pick up. We&#8217;ll take a look at three different programming constructs in three different languages to see how similar they really are. If you&#8217;d like to get started in programming but don&#8217;t know a single thing about it, this article is for you.</p>
<p><span id="more-26023"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>Fear Not, You Just Might Like It</h2>
<p>This site is generally targeted towards designers, and from personal experience I know that approaching programming for the first time as a designer is extremely intimidating. Designers are visual thinkers, we thrive through creation and experimentation using our mind&#8217;s eye and an expert knowledge of the tools of our trade.</p>
<p>Generally, we&#8217;re the kind of people that hated math class and anything else where creativity didn&#8217;t seem to have an obvious foothold.</p>
<div class="pullquote-r">
&#8220;Generally, we&#8217;re the kind of people that hated math class and anything else where creativity didn&#8217;t seem to have an obvious foothold.&#8221;
</div>
<p></ br></p>
<p>Programmers are problem solvers. They love logic puzzles and tinkering with code for hours in the absolute absence of visuals of any kind. Keep in mind that these two categories of people aren&#8217;t mutually exclusive. If you fit both descriptions, you&#8217;ll likely absolutely love programming. </p>
<h3>Not HTML and CSS</h3>
<p>We&#8217;re quickly reaching a point where most web designers know at least a little bit about coding HTML and/or CSS. This experience and knowledge will indeed help you, but perhaps not as much as you might think. </p>
<p>HTML is a *markup language* and CSS is a *style sheet language*, they&#8217;re used primarily to format and insert fairly static content into pre-built pages. How you work with them is in all reality very different from wielding a *scripting language* or *object-oriented programming language*, which are the kind of hardcore programming tools you&#8217;ll find in use on the web today. </p>
<h2>The Big Secret About Programming</h2>
<p>That last part was the bad news, but fear not, there&#8217;s good news on the horizon. If you walk into a bookstore and wander over to the programming section, you&#8217;re likely to be completely intimidated. There are so many different things to learn! This intimidation is furthered when you happen to meet one of the super geniuses that seems to know pretty much all of the programming languages in existence. How in the world do people find the time to learn this stuff? Many beginners are so completely put off at this point that they give up before they ever even try.</p>
<div class="pullquote-r">
&#8220;Programming languages tend to be very similar. Many of them use the same building blocks and similar tool sets to achieve their goals.&#8221;
</div>
<p></ br></p>
<p>The big secret that you don&#8217;t know if you&#8217;ve never really jumped into programming is that programming languages tend to be very similar. Many of them use the same building blocks and similar tool sets to achieve their goals. </p>
<p>I learned this little secret in my first interaction with programming: a Java class in college (not to be confused with JavaScript). Though I myself was a strapping young lad, the class was largely filled with men in their 30s and 40s. Virtually all of them already had jobs in programming and had been at it for twenty years or more. They were simply employed in the use of other languages and attempting to expand their skill set, often at their employer&#8217;s encouragement and expense.</p>
<p>Walking into the class on the first day, none of us knew much, if anything, about Java. However, by the third class, these guys were breezing past me. I was writing horribly simple little code snippets based on the fundamentals that we had learned. These guys were taking the same fundamentals and building elaborate applications with all kinds of cool functions way beyond the requirements for the assignment. </p>
<div class="pullquote-r">
&#8220;Was I inept? It turns out, fortunately for me, that the answer wasn&#8217;t so simple.&#8221;
</div>
<p></ br></p>
<p>Was I inept? It turns out, fortunately for me, that the answer wasn&#8217;t so simple. The reality was that we were learning very different things. I was learning to program through the lens of Java, these guys already knew all about programming and merely needed a little help figuring out how to translate that knowledge into Java. I was a toddler learning to speak for the first time and they were multi-linguals picking up yet another language. </p>
<p>The point of this long story is to illustrate that, after you really get into programming or scripting with one language, the rest becomes much easier because you&#8217;ve dramatically reduced the learning curve. If you know how to code in PHP, the jump to Ruby is much smaller. </p>
<h3>The Building Blocks</h3>
<p>It&#8217;s easy for me to say that programming is built on reusable knowledge, but can I put that into practice? What are these so-called building blocks and how are they similar or different from language to language?</p>
<p>Great question! Let&#8217;s find out by taking a look at some of the most basic but most used programming constructs. Understanding these will jumpstart your programming education regardless of the path or language that you choose to pursue.</p>
<h2>Variables</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/prog101-1.jpg" alt="screenshot" width="510"/></div>
<p>Variables are a wonderful thing. If you&#8217;ve ever used <a href="http://lesscss.org/">LESS</a> or something similar then you&#8217;ve seen the wonders of variables and how they can save immense amount of time. I&#8217;m still not sure if they belong in CSS, but the programmer in me sure wants to see them there.</p>
<p>A variable is essentially a way to store information. You can store something as simple as a value, say 39, or something as complex as an entire array of data containing hundreds of values. Think of a variable as a box. Boxes themselves don&#8217;t seem all that important, it&#8217;s what&#8217;s inside that counts. However, boxes do make for a convenient way to store and access certain items. </p>
<h3>JavaScript Variables</h3>
<p>Let&#8217;s jump to an example. Since JavaScript is a likely first candidate for moving past HTML and CSS, we&#8217;ll start all of our examples there. Here&#8217;s how variables work in JavaScript:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Creating a JavaScript Variable</span>
<span style="color: #003366; font-weight: bold;">var</span> contentWidth<span style="color: #339933;">;</span>
contentWidth <span style="color: #339933;">=</span> <span style="color: #CC0000;">496</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Using the Variable</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>contentWidth<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>Here you can see exactly how variables are used in JavaScript. First, you &#8220;declare&#8221; a variable. This simply creates it or brings it into existence, when doing this you always want to name it something indicative of its contents. Next, you assign it a value (often these two steps are combined), in our case I threw in an arbitrary number. Remember that, &#8220;contentWidth&#8221; is our box, which now holds a value. Any time we want to access that box, we just use the variable name, so to end the example out I created an alert and inserted the variable. This will pop up a box with the value &#8220;496&#8243;. </p>
<p>This may seem useless here but imagine we had three hundred lines of code that referenced that variable frequently. Any time the value of that variable changes, our code still works perfectly because the variable name has stayed constant. Without variables, this would be impossible and much more code would result. </p>
<h3>PHP Variables</h3>
<p>Now that we have that solid foundation of information, learning variables in other languages becomes much easier. This time we&#8217;re not learning what variables are and how they work, only how to use them in other languages. </p>
<p>Here&#8217;s a look at how variables work in PHP:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Creating a PHP Variable</span>
<span style="color: #000088;">$contentWidth</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">496</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Using the Variable</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$contentWidth</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>There&#8217;s a lot of similarity here. Notice the use of semicolons to denote the end of a statement and how comments use the same syntax. This time we declared our variable and assigned it a value in a single line. We can see that the syntax for this is nearly identical, with the important distinction that PHP uses a &#8220;$&#8221; at the beginning of a variable name. Note that the &#8220;echo&#8221; command merely prints something to the browser page.</p>
<h3>Ruby Variables</h3>
<p>Now let&#8217;s take a look at variables in Ruby. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Creating a Ruby Variable</span>
contentWidth = <span style="color:#006666;">496</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Using the Variable</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> contentWidth;</pre></div></div>

</div>
<p></ br></p>
<p>By now you can see that a lot of what&#8217;s involved in learning a new language is just figuring out its various quirks. For instance, JavaScript and PHP used semicolons at the end of a line, Ruby does not. Also, this time around comments are created with  &#8220;#&#8221; instead of &#8220;//&#8221; and we use &#8220;puts&#8221; to output our result. </p>
<h2>Loops</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/prog101-2.jpg" alt="screenshot" width="510"/></div>
<p>Another popular programming construct is a loop. With loops you can save yourself the trouble of repeating code again and again by automating the process you want to achieve. When creating a loop, you must be sure to declare the parameters of the loop, such as the conditions for when the loop will cease. You don&#8217;t want the actions continuing on infinitely so you must create a condition whereby the loop will be terminated. </p>
<h3>JavaScript Loops</h3>
<p>In any given language, there are usually multiple types of loops. Here&#8217;s one type in JavaScript, the &#8220;while&#8221; loop. In this example we set up a variable, then create a chunk of code that should execute again and again for as long as the variable is less than 50. Then within that block of code, we define the actions to be repeated. In this case we&#8217;re logging the value of the variable to the console, then increasing the variable&#8217;s value by one. Since the variable is increasing every time the code runs, it will eventually hit 50 and the loop will terminate. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// JavaScript &quot;while&quot; Loop</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> <span style="color: #CC0000;">25</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span>
	x<span style="color: #339933;">++;</span> <span style="color: #006600; font-style: italic;">// Increases the variable by one</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This same thing could be achieved with a &#8220;for&#8221; loop. This version a little more succinct as is states the value of the variable to start, the condition under which the loop terminates and the action to take on the variable all in one line. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// JavaScript &quot;for&quot; Loop</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> <span style="color: #CC0000;">25</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>x<span style="color: #339933;">=</span><span style="color: #CC0000;">25</span><span style="color: #339933;">;</span>x<span style="color: #339933;">&lt;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">;</span>x<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>PHP Loops</h3>
<p>Once again we find that PHP is very similar to JavaScript. After reading through the examples above, you should be able to effortlessly grasp the PHP equivalent. Here once again we have a while loop and a for loop, each of which contains nearly identical syntax to their JavaScript brethren. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// PHP &quot;while&quot; Loop</span>
&nbsp;
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$x</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$x</span><span style="color: #339933;">++;</span> <span style="color: #666666; font-style: italic;">// Increases the variable by one</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// PHP &quot;for&quot; Loop</span>
&nbsp;
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">25</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$x</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Ruby Loops</h3>
<p>Here are the &#8220;while&#8221; and &#8220;for&#8221; loops in Ruby. As you can begin to see, Ruby is much looser in its syntax than the other two languages we&#8217;re using. Not only are there no semicolons, the curly brackets aren&#8217;t present either. Also notice how different the &#8220;for&#8221; loop looks this time around. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">//</span> Ruby <span style="color:#996600;">&quot;while&quot;</span> <span style="color:#CC0066; font-weight:bold;">Loop</span>
&nbsp;
x = <span style="color:#006666;">25</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">while</span> x <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006666;">50</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> x
  x<span style="color:#006600; font-weight:bold;">+</span>=<span style="color:#006666;">1</span> <span style="color:#008000; font-style:italic;"># Increases the variable by one</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</div>
<p></ br></p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">//</span> Ruby <span style="color:#996600;">&quot;for&quot;</span> <span style="color:#CC0066; font-weight:bold;">Loop</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">for</span> x <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">25</span>..<span style="color:#006666;">50</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> x
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</div>
<p></ br></p>
<h2>Functions</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/prog101-3.jpg" alt="screenshot" width="510"/></div>
<p>Functions are yet another programming construct created to save you time by avoiding repeating the same code. When you code an application, it will probably perform anywhere from one to thousands of tasks. Each task represents a chunk of commands. When we toss the commands into a function we can simply call that function instead of writing out that full code. In this way a function is a lot like a variable that performs a task or list of tasks.</p>
<h3>JavaScript Functions</h3>
<p>Let&#8217;s build a super basic function in JavaScript that takes any number passed to it and squares it. We start here with the word &#8220;function&#8221; then follow it up with a variable in parentheses. Then inside the function we perform various actions and return a value.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Creating the Function</span>
<span style="color: #003366; font-weight: bold;">function</span> squared<span style="color: #009900;">&#40;</span>someNumber<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> someNumber <span style="color: #339933;">*</span> someNumber<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Using the Function</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>squared<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>When we use the function, we replace the parenthetical variable with any number we like and the code inside the function will be performed on that value. In the example above, the result returned would be 81.</p>
<h3>PHP Functions</h3>
<p>By now you&#8217;re so familiar with the JavaScript to PHP conversion that you should be able to do it all by yourself. Here&#8217;s the syntax:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Creating the Function</span>
<span style="color: #000000; font-weight: bold;">function</span> squared<span style="color: #009900;">&#40;</span><span style="color: #000088;">$someNumber</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$someNumber</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$someNumber</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Using the Function</span>
<span style="color: #b1b100;">echo</span> squared<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Ruby Methods</h3>
<p>Once again, Ruby is quite different. In fact, Ruby actually refers to this particular construct as a method, not a function. However, we can still quickly apply our knowledge of functions to decipher how this works.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">//</span> Creating the Function
<span style="color:#9966CC; font-weight:bold;">def</span> squared<span style="color:#006600; font-weight:bold;">&#40;</span>someNumber<span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#0000FF; font-weight:bold;">return</span> someNumber <span style="color:#006600; font-weight:bold;">*</span> someNumber
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">//</span> Using the Function
<span style="color:#CC0066; font-weight:bold;">puts</span> squared<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

</div>
<p></ br></p>
<p>As you can see, the Ruby method is performing the same task as the JavaScript function. It allows you to pass a number into the parameters, after which is squares that number and returns the value. </p>
<h2>Easy Right?</h2>
<p>By now you should be able to see the importance of understanding the practice of programming independently of any programming language. There is a shared structure and method of programming that you&#8217;ll find throughout the languages that you learn. Many of the differences are *semantic* and amount to slight syntax differences.</p>
<p>Don&#8217;t take this to mean that programming and scripting languages are all the same, they&#8217;re not. They all have a specific purpose that defines how and when you use them. It&#8217;s a lot like learning Adobe Illustrator and then jumping to InDesign. You&#8217;re dealing with two different things created for two different purposes, however, there&#8217;s enough similarity that an expert knowledge of one will help you learn your way around the other. </p>
<h2>Conclusion</h2>
<p>This discussion was not in any way meant to be exhaustive. You don&#8217;t now possess a complete fundamental knowledge of programming. Instead, you merely learned about programming in a way that hopefully makes it more approachable. Instead of seeing a mass of completely different languages that you have to learn, you should now see a collection of related practices in which the study of one actually expands your understanding of the others.</p>
<p>So where should you start? As I mentioned above, JavaScript is definitely the place for web designers to begin. Its application is immediately apparent, especially when combined with <a href="http://jquery.com/">jQuery</a>, to the HTML and CSS that you already know. From there the leap to PHP is much more manageable, which might lead you to study Ruby so you can master <a href="http://rubyonrails.org/">Ruby on Rails</a>; the possibilities are limitless!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/javascript/an-designers-introduction-to-programming/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>The Ins and Outs of Dynamic Navigation Menus</title>
		<link>http://designshack.net/articles/navigation/the-ins-and-outs-of-dynamic-navigation-menus/</link>
		<comments>http://designshack.net/articles/navigation/the-ins-and-outs-of-dynamic-navigation-menus/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 14:00:18 +0000</pubDate>
		<dc:creator>Jake Rocheleau</dc:creator>
				<category><![CDATA[Navigation]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[dynamic menu]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=25903</guid>
		<description><![CDATA[All web designers go through phases struggling with creative ideas. It&#8217;s a natural part of the creation cycle, but it can become frustrating as you&#8217;re stuck on a website project for more than a few days. There isn&#8217;t any one-size-fits-all solution. But we can take a moment to analyze the design process for better solutions. [...]]]></description>
			<content:encoded><![CDATA[<p>All web designers go through phases struggling with creative ideas. It&#8217;s a natural part of the creation cycle, but it can become frustrating as you&#8217;re stuck on a website project for more than a few days. There isn&#8217;t any one-size-fits-all solution. But we can take a moment to analyze the design process for better solutions.</p>
<p>The main goal of any website is to lead visitors through your pages. This is accomplished via a navigation of some type, most commonly links. You can build tab bars, banners, block elements, or even float a nav menu off to the side.</p>
<p>Follow us in the guide below as we look through common trends in web navigation menu design. Both designers and developers have come up with tricks for expediting the process of building websites. And we hope to do the same by offering some unique tips for UI navigation.</p>
<p><span id="more-25903"></span></p>
<h2>Plan a Webpage Outline</h2>
<p>Before the design process begins, you should take a moment to consider the many styles of dynamic navigation available to you. You could have fly-out or dropdown sub-menus appear from a nav bar or fixed block, but alternatively you could have sub-links slide, fade in, or maybe you don&#8217;t even need sub-navigation. These are all important ideas to work through before you dive into Photoshop.</p>
<div class="tutorialimage"><a href="http://www.fork-cms.com/"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/fork-cms-homepage-buttons.jpg" alt="Fork CMS Top nav design" width="510" /></a></div>
<p>With the above example, Fork CMS is using a simple top-bar navigation which fits in very well. Nothing comes off as confusing or difficult to find and you have access to all of the <strong>important</strong> site information.</p>
<p>Your situation may greatly differ based on the number of important pages in your own website. This is why I suggest sketching out a diagram to build a more solid idea of how the navigation should work. This could take the form of a flowchart, where you draw in arrows to point towards the next page in a segment.</p>
<h2>Attaching Sub-Menus</h2>
<p>As an example, the popular design magazine <a href="http://speckyboy.com/">Speckyboy</a> features a sub-nav dropdown menu within each category. WordPress can set this up by default but you still need to utilize some form of jQuery. Meanwhile the niche gaming site <a href="http://www.destinyislands.com/">Destiny Islands</a> uses jQuery for a slide-down sub-menu for each game in the sidebar area.</p>
<div class="tutorialimage"><a href="http://www.destinyislands.com/"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/destiny-islands-nav-sliding.jpg" alt="Destiny Islands a Kingdom Hearts jQuery retreat" width="510" /></a></div>
<p>You may also notice the header navigation is coupled with replacement images on mouseover. This small effect is handy if your layout works well holding fixed-width link buttons. jQuery is an option but <a href="http://blog.w3conversions.com/2011/03/changing-a-background-image-with-css3-transitions/">CSS3 transitions</a> may feel like a better alternative. Both CSS3 and JavaScript boast flaky support in mobile OS&#8217;, But for older legacy browsers you&#8217;re likely to see more success using a jQuery-based method.</p>
<div class="tutorialimage"><a href="http://www.smashingmagazine.com/"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/smashing-magazine-frontpage-nav.jpg" alt="Smashing Magazine redesign homepage" width="510" /></a></div>
<p>And a sub-menu doesn&#8217;t have to stick within the standard formats, either. I think the newest <a href="http://www.smashingmagazine.com/">Smashing Magazine</a> re-design says it best with their small tag cloud. Hover over the icon next to their site logo and a menu of blog categories and tags appear. Keep these small yet refined ideas in mind for your own pop-out menus.</p>
<h2>Ajax Tabs</h2>
<p>To contain a large number of links in a smaller area, some content needs to be hidden by default. Hidden dropdown menus are one way, but a container with tabs is another option. And with Ajax you can asynchronously pull out data from your database or another webpage with each different tab on the div.</p>
<div class="tutorialimage"><a href="http://www.webdesignerdepot.com/"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/webdesigner-depot-sidebar-posts.jpg" alt="Webdesigner Depot home sidebar widget" width="510" /></a></div>
<p>WordPress blogs are notorious for these kinds of features. The above screenshot from Webdesigner Depot focuses on a sidebar widget to pull out the most popular and recent articles. If you feel this method will suit your layout, it is one way of containing links in a very reduced space.</p>
<h2>If You Go Big, Go Fancy!</h2>
<p>Those of you who frequent design galleries have most likely stumbled across Coda&#8217;s page before. They use both a tabbed content area for loading dynamic information and a heading area with 3 links: <strong>Download</strong>, <strong>Buy</strong>, and <strong>Help</strong>.</p>
<div class="tutorialimage"><a href="http://www.panic.com/coda/"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/coda-home-screen-app.jpg" alt="Code App for Mac OS X" width="510" /></a></div>
<p>This is just one perfect example of taking your web navigation to the next level. Big and bold lettering is often attention-grabbing if designed appropriately. And the hover effects added over each link area tack onto the <strong>magical</strong> feeling of the whole layout. This is all without mentioning the delicious pixel-crazed icons featured next to each large block.</p>
<p>This is a very flashy display of website effects and will not always be realistic within the scope of every project. But for low-numbered navigation links it&#8217;s almost better to jack up the size quite a bit. If you only have 3-4 pages these should be easily found and glossed over exquisitely. As for the icons, there are <a href="http://www.iconfinder.com/">so many resources</a> to <a href="http://findicons.com/">check out</a> it&#8217;s most likely you&#8217;ll run into something cool!</p>
<h2>Ruling HTML5 Standards</h2>
<p>The web has advanced a long way since 2001. In the past 10 years we have seen tremendous leaps of innovation between techies all around the world. And now HTML5 has swept the design world by storm offering a sound, stable declaration for even some convoluted page elements.</p>
<p>One such example is the <a href="http://www.w3schools.com/html5/tag_nav.asp">&lt;nav&gt; tag</a> which is slowly taking over the unordered list formats (or even coupling the two together). Here&#8217;s a great <a href="http://stackoverflow.com/questions/5178761/html5-nav-tag-correct-usage">Stack Overflow question</a> about semantic HTML and using the nav element properly. As quoted from the specs page &#8220;<em>the nav element represents a section of a page that <strong>links to other pages</strong> or to parts within the page</em>&#8220;.</p>
<div class="tutorialimage"><a href="http://www.flickr.com/photos/44963760@N05/4206280417/"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/okayama-prefecture-coaster.jpg" alt="street lights in Japan roller coaster theme park" width="510" /></a></div>
<p>A personal favorite article published earlier this year is titled <a href="http://blog.echoenduring.com/2011/02/23/how-html5-changes-the-way-we-think-of-navigation/">How HTML5 Changes the Way We Think of Navigation</a> and expresses a lot of strong benefits towards the switch in coding. The basic confusion stems from so many developers growing accustomed to XHTML and HTML 4.01 standards.</p>
<h2>Conclusion</h2>
<p>This guide has looked more into the semantics and markup of building a dynamic navigation menu. Between the new CSS3 animation effects and jQuery UI library there are tons of customizations you can build. Front-end web development has never been this much fun! And it&#8217;s easy to find great support communities for newbie developers just picking up the trade.</p>
<p>Have you built any dynamic menu systems on your own website? Or maybe you&#8217;ve run into a few really cool effects on other websites. Let us know your thoughts and ideas in the discussion area below.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/navigation/the-ins-and-outs-of-dynamic-navigation-menus/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating an Apple-Style Input Field With Display Labels</title>
		<link>http://designshack.net/articles/css/creating-an-apple-style-input-field-with-display-labels/</link>
		<comments>http://designshack.net/articles/css/creating-an-apple-style-input-field-with-display-labels/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 20:31:47 +0000</pubDate>
		<dc:creator>Jake Rocheleau</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[poshytips]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=23108</guid>
		<description><![CDATA[Apple is a very popular brand in the new technological age in which we live. Both designers and developers agree that Apple&#8217;s products display exquisite talent and passion for their skills. Over time user interface design has taken a turn upwards and is now one of the hottest topics amongst web designers. Below I&#8217;ll be [...]]]></description>
			<content:encoded><![CDATA[<p>Apple is a very popular brand in the new technological age in which we live. Both designers and developers agree that Apple&#8217;s products display exquisite talent and passion for their skills. Over time user interface design has taken a turn upwards and is now one of the hottest topics amongst web designers.</p>
<p>Below I&#8217;ll be going over how to build a small Apple-styled input form with some basic structure and scripting. All code included is based off XHTML Transitional Doctype along with newer CSS2/CSS3 techniques. We&#8217;ll also be using the jQuery 1.4.1 library to support our display label functions.</p>
<p><span id="more-23108"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>Try It Out</h2>
<p>Here&#8217;s a sneak peak of what we&#8217;ll be building. Check out the demo page to see it live and download the example for a closer look.</p>
<p><strong><a href="http://designshack.net/tutorialexamples/AppleJake/index.html">Live Demo</a> &#8211; <a href="http://designshack.net/tutorialexamples/AppleJake/apple-display-fields.zip">Download</a></strong></p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/project-demo.jpg" alt="jQuery Apple Input Field - Demo Graphic" width="510" /></div>
<h2>Building our HTML and CSS</h2>
<p>Before we can start developing it&#8217;s important to get frontend code structure in order. Luckily this process is very simple and shouldn&#8217;t take long at all to complete. Below I&#8217;ve included a stripped copy of the HTML code from our example &#8220;index.html&#8221; document. This should all be standard code to display a very basic input form, nothing further than any basic HTML developer&#8217;s knowledge.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><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>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <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>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Apple-style Input Field<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<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;c&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;basicform&quot;</span> <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;post&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <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;username&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unameblock&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter your username&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;u1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pwblock&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter your password&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;u1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submitbtn&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit Button!&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

</div>
<p>Here I&#8217;ve set up 2 very important input elements under the IDs &#8220;unameblock&#8221; and &#8220;pwblock&#8221;. These stand for <strong>username block</strong> and <strong>password block</strong>, respectively, and will be very important later in our script. Now that our code is looking good it would be wise to jump into CSS styles.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/web-designer-magazine-html5.jpg" alt="HTML5 Code - Web Designer Mag UK" width="510" /></div>
<p>These are the real bare-bones structure rules since CSS is what gives all HTML elements their form. There aren&#8217;t many changes we will be including. Some basic resets for global variables along with alignment and positioning for input fields. Below are clips from the source code, explained in bit intervals.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#dbe9f7</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#c</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;">850px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p>Here we have our global reset with the <em>asterisk</em> (*) selector removing all browser-standard margins and padding. We also give some styles to the body element for positioning our form front and center. The #c division is our container div which has been centered for the sake of our demo.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">input<span style="color: #6666ff;">.u1</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span> <span style="color: #933;">12px</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;">1.6em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#787878</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;">-0.02em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">1px</span> <span style="color: #933;">0px</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#e0e0e0</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#e0e0e0</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	<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;">#717171</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #933;">0px</span> <span style="color: #cc00cc;">#efefef</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #933;">0px</span> <span style="color: #cc00cc;">#efefef</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span>  <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #933;">0px</span> <span style="color: #cc00cc;">#efefef</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
input<span style="color: #cc00cc;">#submitbtn</span> <span style="color: #00AA00;">&#123;</span> <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> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #933;">9px</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> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</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;">-0.05em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#444</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
input<span style="color: #6666ff;">.fail</span> <span style="color: #00AA00;">&#123;</span> -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#ff4848</span><span style="color: #00AA00;">;</span> -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#ff4848</span><span style="color: #00AA00;">;</span> box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#ff4848</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
input<span style="color: #3333ff;">:focus </span><span style="color: #00AA00;">&#123;</span> -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#007eff</span><span style="color: #00AA00;">;</span> -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#007eff</span><span style="color: #00AA00;">;</span> box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">5px</span> <span style="color: #cc00cc;">#007eff</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p>The first noticeable block is used to style our input fields. It targets all input elements with a class of &#8220;u1&#8243; which both our username and password fields run. Instead of placing 10-20 style declarations on a single line it&#8217;s much easier for editing to keep this in block-level.</p>
<p>In here we have the styles to configure how our input fields will look. Padding, font-size, among many borders and text manipulation properties as well. We&#8217;re using many new CSS3 techniques here which should be apparent to all CSS developers.</p>
<h2>New CSS3 Entities</h2>
<p>Two brand new CSS3 functions we&#8217;re using are <code>-webkit-gradient</code> and <code>-moz-linear-gradient</code> which can generate gradients on-the-fly. This is an amazing feature which hasn&#8217;t been discussed in many CSS3 articles. This removes the need for any images in creating standards-compliant background gradients.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/mac-osx-office-space.jpg" alt="Mac OS X Home Working Office" width="510" /></div>
<p>We also have <code>-webkit-box-shadow</code> and <code>-moz-box-shadow</code>. Similar naming schemes help with confusing between Webkit browsers and Mozilla-based Gecko browsers.</p>
<p>Further down we have 3 more styles which attack our submit button along with states for our input forms. The <em>:focus</em> pseudo-targeting means CSS will only apply our styles when the user is focused on either input field. These styles will display a blue glow for focus and red glow for errors (very useful when debugging user logins and registration forms).</p>
<p>So far this all looks great! In fact all we need to do is include a few scripts/styles in our header section to really get started on our dynamic effects. If you take the current document and include our stylesheet we can get the hover effects immediately.</p>
<h2>Working with jQuery Effects</h2>
<p>jQuery is an amazing JavaScript library which has proven useful time and again. Your average web developer is heavily focused on speed and precision of scripting. This is something jQuery takes in and internalizes with their ideas.</p>
<p>Below is a small section which needs to be added between the <code>head</code> tags of your document. I&#8217;ll explain a few of these below and also get into some of the behind-the-scenes code.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <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: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <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/tip-yellowsimple.css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</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;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</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;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;src/jquery.poshytip.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

</div>
<p>Our style.css is the file which includes all of our CSS rules listed above. Another inclusion is <strong>tip-yellowsimple.css</strong> which hasn&#8217;t been mentioned yet. It&#8217;s a script written through jQuery as a plug-in for tooltip hovers. With this stylesheet (download with demo source) we are able to style tooltips on any action.</p>
<p>Our two JavaScript files are really basic and self-explanatory. We&#8217;re accessing jQuery 1.4.1 min so as to cut down on processing and download speeds. We&#8217;re also reading through Google&#8217;s APIs code database which stores all previous and active versions of popular scripts. This is a tremendous effort and helps development projects surge forward without the need to constantly download the jQuery library manually.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/poshytips-design-blog-download.jpg" alt="JavaScript PoshyTips with jQuery" width="510" /></div>
<p>The second file we have &#8220;jquery.poshytip.js&#8221; contains our plug-in code. Poshytip is a jQuery class written by <a href="http://vadikom.com/">Vasil Dinkov</a> to support dynamic tooltips. The code is vast and unnecessary to learn in-detail. However if you&#8217;re a jQuery geek feel free to check out his manual efforts to see how these methods are called and what variables you could edit.</p>
<h2>Basic Action Call</h2>
<p>All we need now is our infamous call to action! This is our main function which will load on document load and prepare to launch upon whatever signal we call. In this case we&#8217;re looking for an event which happens when a user focuses on one of the input fields.</p>
<p>One last step is to add this code into the head beneath all our file includes. This is straight JavaScript code so it should be encapsulated with a <code>script</code> tag. For easing I&#8217;ve removed the tags in the code below so we can focus on just the js functionality.</p>
<div style="overflow: auto;background-color: #eeeeee">

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">$(function(){
	$('#unameblock').poshytip({
		className: 'tip-yellowsimple',
		showOn: 'focus',
		alignTo: 'target',
		alignX: 'inner-left',
		alignY: 'top',
		offsetX: 10
	});
&nbsp;
	$('#pwblock').poshytip({
		className: 'tip-yellowsimple',
		showOn: 'focus',
		alignTo: 'target',
		alignX: 'inner-left',
		alignY: 'top',
		offsetX: 10
	});
});</pre></div></div>

</div>
<p>So what we&#8217;re doing is calling a generic <code>function() {}</code> to check on some events. We are creating 2 new instances of the <code>poshytip()</code> method based off our input forms. This can be seen when we parse the DOM for the element IDs &#8220;unameblock&#8221; and &#8220;pwblock&#8221;.</p>
<p>Each of the individual settings in place expands on the functionality of poshytip. If you&#8217;d like to view <a href="http://vadikom.com/demos/poshytip/#methods">documentation for all methods</a> there is a great collection which Vasil has put online. Namely <em>showOn</em> is our most important variable which tells the parsing engine to check for any focus activity in these two elements.</p>
<p>AlignX and AlignY are important in regards to placement. These hold the values for where our tooltip will show up in page. This can be bottom, center, top, along with offset placements such as inner-left and inner-right. Try messing with these if you&#8217;d rather have the tooltips pop up on the side or bottom instead of the top.</p>
<p>What you may not have noticed by now is where our text is loaded from. Poshytips makes it simple here, too, where the value of our <em>title</em> attribute is displayed in tooltip text. This makes targeting specific elements extremely simple and very productive!</p>
<h2>Conclusion</h2>
<p>These are some of the most basic steps towards building an Apple-style input field. There are many other unique effects which can be applied using jQuery that range out of the scope on this tutorial. Check out some demos from Apple&#8217;s website for more inspiration. Also if you&#8217;d like to download the entire demo package you can <a href="http://designshack.net/tutorialexamples/AppleJake/apple-display-fields.zip">do so here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/creating-an-apple-style-input-field-with-display-labels/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Book Review: Eloquent Javascript</title>
		<link>http://designshack.net/articles/reviews/book-review-eloquent-javascript/</link>
		<comments>http://designshack.net/articles/reviews/book-review-eloquent-javascript/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 14:00:34 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[eloquent javascript]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=21932</guid>
		<description><![CDATA[Most web designers these days know at least a little HTML and CSS, giving them the ability to bring their designs to the web. Advanced functionality, for the most part though, is handled by programming languages, which have a much higher barrier to entry. This leaves countless designers intimidated while wishing they had a firmer [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eloquentjavascript-1.jpg" alt="screenshot" width="510"/></div>
<p>Most web designers these days know at least a little HTML and CSS, giving them the ability to bring their designs to the web. Advanced functionality, for the most part though, is handled by programming languages, which have a much higher barrier to entry. This leaves countless designers intimidated while wishing they had a firmer grasp of the most essential of these: JavaScript.</p>
<p>Do you wish you could finally scratch &#8220;learn JavaScript&#8221; off of your todo list? Does a hefty learning curve keep you from taking the plunge? Maybe you just need the right book. Today we&#8217;ll take a look at <em>&#8220;<a href="http://www.amazon.com/gp/product/1593272820?ie=UTF8&#038;tag=marijhaver-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1593272820">Eloquent Javascript:</a> A Modern Introduction to Programming&#8221;</em> by Marijn Haverbeke to see if it&#8217;s what you need to become a JavaScript ninja.</p>
<p><span id="more-21932"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>A Manageable Task</h2>
<p>I have a JavaScript book in my closet that I picked up in college a few years ago. It&#8217;s 1,000 pages long and is heavier than a good family bible. After one look at this impressive tome, most non-programmers would give in to the hopelessness of actually having the time to learn and master the material within.</p>
<p>As I mentioned in the introduction, if it&#8217;s your first foray into real programming, JavaScript can be pretty intimidating and the last thing you want to find out is that you&#8217;ll need to get a new degree just to understand it.</p>
<p>The very first thing you&#8217;ll notice about &#8220;Eloquent JavaScript&#8221; is its size, especially if you&#8217;ve come face to face with one of the beast manuals I just mentioned. This book, by contrast, is thin, light and comes in at under 200 pages of reading material! </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eloquentjavascript-2.jpg" alt="screenshot" width="510"/></div>
<p>One look at this book and you feel a sense of relief: I can do this. The task before you is still challenging, but feels much more like a long jog than a decathlon. </p>
<h2>Who Is It For? Absolute Beginners!</h2>
<p>Given the fact that it&#8217;s a fairly brief volume, you might expect that there is a lot of knowledge that you need going into it, but make no mistake, this book is perfect for someone who has never written a line of JavaScript in their life.</p>
<p>Of course, it&#8217;s definitely recommended that you figure out HTML and CSS first if  building webpages and web applications is your ultimate goal. In truth, you could make it through most of the content in the book just fine without these skills, but they really help put the information into context; I guarantee that it will make more sense if you figure out the basics first.</p>
<p>An interesting thing about programming is that the biggest hurdle to learning your first language is actually learning the process of programming. Once you learn this, picking up new languages is more of a matter of mastering semantics than learning from scratch. One of this book&#8217;s primary focuses is to teach you how to program. This will prove an invaluable skill as you expand your knowledge in the future. </p>
<h2>Who Wrote It?</h2>
<p>Marijn Haverbeke is a programmer and tech writer with an impressively large body of open source projects such as <a href="http://codemirror.net/">Code Mirror</a> and <a href="http://marijnhaverbeke.nl/mold">Mold</a>.</p>
<p>Though, from what I can tell, this is his first book, he does have a ton of writing experience on technical topics ranging from JavaScript to <a href="http://marijnhaverbeke.nl/turtle/">Machine Fundamentals</a>.</p>
<p>Haverbeke&#8217;s writing style definitely helps make a fairly dull and technical subject more approachable. He&#8217;s quite fond of using bizarre circumstances and humor to make his point. For instance, one project in the book is explained through a narrative about a recluse whose hut is struck by lighting, which results in him being burned alive. Needless to say, it&#8217;s not your typical JavaScript introduction. </p>
<h2>What&#8217;s In It?</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eloquentjavascript-3.jpg" alt="screenshot" width="510"/></div>
<p>In the introduction, Haverbeke writes a great little summary of all of the twelve chapters. I&#8217;ll be using select quotes from this to explain and divide each section.</p>
<h3>Introduction</h3>
<p><em>&#8220;The first three chapters will introduce the JavaScript language and teach you how to write grammatically correct JavaScript programs.&#8221;</em></p>
<ul>
<li>Chapter 1: Basic JavaScript: Values, Variables and Control Flow</li>
<li>Chapter 2: Functions</li>
<li>Chapter 3: Data Structures: Objects and Arrays</li>
</ul>
<h3>Advanced Techniques</h3>
<p><em>&#8220;The next four chapters discuss more advanced techniques–things that should make you capable of writing more complicated programs without them turning into an incomprehensible mess.&#8221;</em></p>
<ul>
<li>Chapter 4: Error Handling</li>
<li>Chapter 5: Functional Programming</li>
<li>Chapter 6: Object-Oriented Programming</li>
<li>Chapter 7: Modularity</li>
</ul>
<h3>Tools</h3>
<p><em>&#8220;The remaining chapters focus less on theory and more on the tools that are available in a JavaScript Environment.&#8221;</em></p>
<ul>
<li>Chapter 8: Regular Expressions</li>
<li>Chapter 9: Web programming: A crash course</li>
<li>Chapter 10: The Document Object Model</li>
<li>Chapter 11: Browser Events</li>
<li>Chapter 12: HTTP requests</li>
</ul>
<h2>How Is It?</h2>
<p>&#8220;Eloquent JavaScript&#8221; does an admirable job of making the complex simple. It actually goes through a ton of theory very quickly by giving you enough to gain an understanding without being so much that it overwhelms you and puts you to sleep. As I mentioned above, the author has an entertaining writing style that I particularly enjoyed. </p>
<p>As previously stated, the book itself is around 200 pages. If you&#8217;re looking for something full-color with lots of pretty pictures to keep you interested, look elsewhere. This book is largely text and code snippets and contains only a few quick and simple B&#038;W images (this translates to a fairly low price). Visual learners that like a lot of charts and tables may not find what they&#8217;re looking for here. </p>
<p>One thing that I would&#8217;ve like to have seen is more solid explanation and examples for how to put the theory into practice in real life websites. A lot of people don&#8217;t really have a strong grasp of what to use JavaScript for outside of big web applications and some more guidance for daily use would&#8217;ve gone a long way.</p>
<div style="overflow: auto; color: 4e4e4e; background-color: #eeeeee; float: right; width: 250px; margin: 20px 0 20px 20px; padding: 20px; font: italic 20px/30px Georgia, serif; border: 1px solid #ccc;">
&#8220;Eloquent JavaScript is surely among the best original book on the subject in recent years.&#8221;
</div>
<p></ br></p>
<p>On the whole though, it&#8217;s a fantastic book. HTML and CSS are the type of thing that can be picked up easily from scattered free tutorials online but JavaScript is one of those things that seems best to learn from start to finish in a consistent and structured volume. &#8220;Eloquent JavaScript&#8221; is surely among the best original book on the subject in recent years, though I can easily imagine the publisher expanding this into a series: Eloquent PHP, Eloquent CSS, etc.</p>
<p>The bottom line is, if you&#8217;re still reading at this point, you&#8217;re probably someone who genuinely wants and needs to learn JavaScript. A $30 book that promises to help you achieve this in less than 200 pages is possibly too good to pass up. </p>
<h2>Conclusion</h2>
<p>To sum up, &#8220;Eloquent JavaScript&#8221; is a truly great book for absolute beginners to learn the foundations of both JavaScript and programming in general. It strikes a perfect balance between being brief and lighthearted and thorough enough to give you an extensive knowledge of the subject.</p>
<p>If you&#8217;re at all interested in learning JavaScript, making this your first guide could mean the difference between getting discouraged and giving up and really getting into programming as a lifelong venture. </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/reviews/book-review-eloquent-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using eCSStender to Clean Up Your CSS</title>
		<link>http://designshack.net/articles/css/using-ecsstender-to-clean-up-your-css/</link>
		<comments>http://designshack.net/articles/css/using-ecsstender-to-clean-up-your-css/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 14:00:50 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[eccstender]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[less]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=11456</guid>
		<description><![CDATA[Recently we looked at how to use LESS.js to enhance your CSS and save you tons of development time. Today we&#8217;ll look at eCSStender, another JavaScript tool that enables you to implement complicated CSS3 properties with very little code. eCSStender can be a bit confusing to figure out on your own but once you figure [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we looked at how to <a href="http://designshack.net/articles/css/using-less-js-to-simplify-your-css3">use LESS.js to enhance your CSS</a> and save you tons of development time. Today we&#8217;ll look at eCSStender, another JavaScript tool that enables you to implement complicated CSS3 properties with very little code. </p>
<p>eCSStender can be a bit confusing to figure out on your own but once you figure it all out it will literally take you less than a minute to install and use. Below I&#8217;ll walk you through building a basic example that uses a number of eCSStender extensions. </p>
<p><span id="more-11456"></span></p>
<p><em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>What Is eCSStender?</h2>
<p>The basic workflow of eCSStender is as follows: find and download an extension, throw it in your website directory, link to it in your HTML, implement the CSS. </p>
<p>The major benefits of eCSStender were discussed in detail in Aaron Gustafson&#8217;s recent article, <a href="http://www.alistapart.com/articles/stop-forking-with-css3/">Stop Forking with CSS3</a> (Aaron Gustafson is the creator of eCSStender). One of the biggest problems with CSS3 is of course the lengthy code necessary to implement it in a cross-browser manner. </p>
<p>For instance, if we have a simple box that we want to give rounded corners and a drop shadow, the following code is necessary:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.myBox</span> <span style="color: #00AA00;">&#123;</span>
  -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* FF1+ */</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Saf3-4 */</span>
  border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Opera 10.5, IE 9, Saf5, Chrome */</span>
  -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">4px</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* FF3.5+ */</span>
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">4px</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Saf3.0+, Chrome */</span>
  box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">4px</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Opera 10.5, IE 9.0 */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>We&#8217;re essentially only adding two styles, yet it takes six lines of code! eCSStender reduces the work necessary here by allowing you to type a single line of code that automatically executes all of the recommended style versions. </p>
<p>To see how this works, let&#8217;s build a basic example.</p>
<h2>The Box</h2>
<p>To keep things ridiculously simple, let&#8217;s just build a web page with a square and some text. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eCSStender-1.jpg" alt="screenshot" width="510"/></div>
<p>The markup here is super basic. Here&#8217;s the HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span>
<span style="color: #00bbdd;">       &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
       <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <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>
       <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>sCSStender Test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
       <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style.css&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;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
	<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;theBox&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</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;#&quot;</span>&gt;</span>eCSStender<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<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;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>And here&#8217;s the CSS at this point:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#83d9c5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#theBox</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</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;">50px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<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>
	<span style="color: #000000; font-weight: bold;">letter-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-2px</span><span style="color: #00AA00;">;</span>
&nbsp;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#theBox</span> a <span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</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;">#123a31</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;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#theBox</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#1e6152</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Downloading eCSStender</h2>
<p>To make our boring box more exciting, we&#8217;ll first need to <a href="http://ecsstender.org/">download eCSStender</a>. What you get in this download is a big mess of files that will leave you confused and intimidated. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eCSStender-2.jpg" alt="screenshot" width="510"/></div>
<p>Fortunately, you only need to worry about a single file here. Just grab &#8220;eCSStender.js&#8221; from the &#8220;src&#8221; folder and toss the rest. Advanced users should feel free to dig through all of the examples and documentation but for the purposes of this tutorial the main JavaScript file will do just fine all by itself.</p>
<h2>Downloading Extensions</h2>
<p>eCSStender doesn&#8217;t do much right out of the box. Instead, you create and/or download free extensions to complement your needs. Head over to the <a href="http://ecsstender.org/extensions">eCSStender Extensions</a> page to see what&#8217;s available. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eCSStender-3.jpg" alt="screenshot" width="510"/></div>
<p>As you can see, eCSStender is still in the early stages of development so there is only a handful of extensions at the moment, some of which are still under construction. </p>
<p>When you click on one of the links shown above you&#8217;ll be taken to a page where you can download the extension, see a demo, and learn about its implementation. </p>
<h2>Our First Test: Rounded Corners</h2>
<p>To see how this all works, download the backgrounds and borders extension. Here again you are going to get a pretty hefty download just to nab a single file. Grab the file named &#8220;eCSStender.css3-backgrounds-and-borders.js&#8221; and toss it in your website directory. </p>
<h3>Linking the Files</h3>
<p>Now that we have both eCSStender and an extension installed, it&#8217;s time to load them into your HTML document. This is done exactly like any other .js file, just throw in a link in the head portion of your document.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</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;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;eCSStender.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</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;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;eCSStenderBB.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>As you can see, I decided that the filename for the backgrounds and borders extension was way too long and renamed it &#8220;eCSStenderBB.js&#8221; to keep things simple. Feel free to ignore this step if you like, just make sure your filenames match that shown in your HTML. </p>
<h3>The CSS</h3>
<p>As you can see, there really hasn&#8217;t been much work thus far. Most of the content above is explanation, background, etc. All we&#8217;ve really done up to this point is download a file and link it in our HTML, very much like you&#8217;d do with jQuery. </p>
<p>When you implement a given extension in the CSS of your site, be sure to consult the download page for proper syntax. In our case, the following code gets the job done:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">25px</span> <span style="color: #933;">50px</span> <span style="color: #933;">75px</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>That&#8217;s all there is to it. eCSStender will do its magic and make sure that this code is appropriately transformed to work in most modern browsers. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eCSStender-4.jpg" alt="screenshot" width="510"/></div>
<p>Now, you&#8217;ll notice that this gave us a pretty funky shape. That&#8217;s because each corner is set to a different radius. I do sort of like the basic idea here though so I&#8217;m going to reset that so that one corner is fairly sharp and the others are uniformly rounded to a greater degree.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">25px</span> <span style="color: #933;">75px</span> <span style="color: #933;">75px</span> <span style="color: #933;">75px</span><span style="color: #00AA00;">;</span></pre></div></div>

<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eCSStender-5.jpg" alt="screenshot" width="510"/></div>
<h2>Adding More</h2>
<p>Just to make sure you get the gist, let&#8217;s add two more properties. First, download both the <a href="http://ecsstender.org/extensions/css3-transitions/">transition</a> and <a href="http://ecsstender.org/extensions/css3-transforms/">transform</a> extensions.</p>
<p>Grab the necessary .js files just as with the previous example and toss them into your site folder. From each extension&#8217;s download page we can see that the syntax is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
transform-origin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>-15deg<span style="color: #00AA00;">&#41;</span></pre></div></div>

<p>As you can see, the transition syntax is fairly basic: select what to transition, set a duration, and set an ease. With the transform property you have to first set an origin, then list the transform you want to take place along with a numerical indicator. In this case we rotated the object 15 degrees.</p>
<p>So to apply this to our example, let&#8217;s make a fun hover effect.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/eCSStender-6.jpg" alt="screenshot" width="510"/></div>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#theBox</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</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;">30px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<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>
	<span style="color: #000000; font-weight: bold;">letter-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-2px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#theBox</span> a <span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</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;">#123a31</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;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">25px</span> <span style="color: #933;">75px</span> <span style="color: #933;">75px</span> <span style="color: #933;">75px</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">15px</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#123a31</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#theBox</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#1e6152</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;">50px</span><span style="color: #00AA00;">;</span>
	transform-origin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>-15deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>So now when you hover over the box, it will rotate, change color, and change font-size all with a nice transition.</p>
<p>Each one of these CSS3 properties would&#8217;ve normally taken around four lines of code. So as you can see, we&#8217;ve definitely saved ourselves quite a bit of coding. </p>
<h2>eCSStender vs. LESS: What&#8217;s the Verdict?</h2>
<p>Overall eCSSstender was definitely fun to play with. However, because I&#8217;ve been toying around with a lot of these CSS tools lately, I simply can&#8217;t help but compare them all to LESS.</p>
<p>Let&#8217;s take a look a few of the areas where each system excels. Out of the box, LESS feels more powerful because it turns CSS into a real programming language with variables, operations etc. This adds a certain flexibility to the coding and syntax that you don&#8217;t get with eCSStender. LESS also doesn&#8217;t require users to hunt down and download multiple extensions and link to a plethora of JS docs. Finally, LESS can be used immediately by anyone without concern for compatibility because what is ultimately uploaded is plain old CSS. </p>
<p>eCSStender makes it easy for developers to create custom plugins so in the long term, this might actually be the more powerful and robust solution (as long as developers jump on board). eCSStender is also nice because you can skip the compiling step inherent in the LESS method (.LESS files are compiled to .CSS files). There are also a few more technical reasons you might like eCSStender better found under the <a href="http://ecsstender.org/faq">FAQ section</a>. For instance, &#8220;a pre-processor [like LESS] can’t leverage that nuance to implement JavaScript-based animations as an alternative to CSS-based ones if they aren’t supported the because pre-processors (as they are currently built) take a “one size fits all” approach to handling CSS: everyone gets the same thing.&#8221;</p>
<p>However, despite all this, even the eCSStender website admits that it&#8217;s simply not all that practical to use in many circumstances. For my own part, I can&#8217;t see myself ever really using eCSStender for more than a little fun and experimentation (unless some big changes are made). </p>
<p>For whatever reason, eCSStender just took a lot more &#8220;fiddling&#8221; than LESS to get everything working properly. For instance, I&#8217;d get eCSStender up and running on Safari, but then it wouldn&#8217;t work in Chrome (bizarre since they&#8217;re both Webkit) and would frequently crash Firefox.</p>
<p>Ultimately, tools like these are intended to improve and simplify your workflow. Give them a shot for yourself to see if that intention actually plays out. If SASS, LESS, eCSStender, or any other similar tools result in actually adding time to your coding process, then toss them and revert back to good old HTML and CSS the way they were intended to be.</p>
<h2>Join the Conversation</h2>
<p>Leave a comment below and let us know which CSS extending or modifying tools you&#8217;ve tried. Tell us what you think of LESS and eCSStender. Do you like one and hate the other, love them both, or can&#8217;t see a reason for either to exist? </p>
<p>As developers in the real world, you ultimately decide what gets adopted and what doesn&#8217;t and we want to hear your opinions!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/using-ecsstender-to-clean-up-your-css/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Best of 2008 &#8211; JavaScript</title>
		<link>http://designshack.net/articles/best-of-2008-javascript/</link>
		<comments>http://designshack.net/articles/best-of-2008-javascript/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 11:57:21 +0000</pubDate>
		<dc:creator>Kishore Nallan</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[top]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=545</guid>
		<description><![CDATA[In the last part of our summary series, it is time to see some of the JavaScript Goodies of 2008. Some of the following are resources, some are useful tutorials, some opinions and others just plain fun interesting stuff. There is always a lesson or two to take away from these, and it could help [...]]]></description>
			<content:encoded><![CDATA[<p> In the last part of our summary series, it is time to see some of the JavaScript Goodies of 2008. Some of the following are resources, some are useful tutorials, some opinions and others just plain fun interesting stuff.</p>
<p>There is always a lesson or two to take away from these, and it could help you enter the New Year with a variety of new skills in your portfolio.</p>
<p><span id="more-545"></span></p>
<h2>sIFR Lite </h2>
<p><em>&ldquo;</em>Once upon a time some really good web developers created sIFR. Their goal was to seamlessly convert HTML headlines into nice fonts. Well, these developers did a great job getting it to work nicely. Looking at their code, I decided I would create a &quot;lite&quot; version of sIFR using a more object-oriented approach. sIFR Lite is a bit easier to read, and more intuitive to use.&rdquo;</p>
<p><a href="http://www.allcrunchy.com/Web_Stuff/sIFR_lite/" class="smallbox">Visit site</a></p>
<h2>DD_belatedPNG</h2>
<p>Support for 24-bit PNG alpha-translucency background-image + background-position + background-repeat for IE 6 at last!</p>
<p><a href="http://dillerdesign.com/experiment/DD_belatedPNG/" class="smallbox">Visit site</a></p>
<h2>The EqualHeights jQuery Plugin</h2>
<p>&ldquo;Creating equal-height columns with CSS is sometimes a bear. But who  needs the hassle of faux columns, &ldquo;clear&rdquo; divs and the rest? With this  bit of jQuery, you can easily equalize the heights of any group of  elements.&rdquo;</p>
<p><a href="http://www.cssnewbie.com/equalheights-jquery-plugin/" class="smallbox">Visit site</a></p>
<h2>jQuery.popeye &#8211; an inline lightbox alternative</h2>
<p>&ldquo;The plugin transforms an unoredered list of images into a box  displaying only one preview image at a time. The box has controls to  skim through the preview images and to enlarge a given image. The box  expands to accomodate the enlarged version, while the controls are  hidden in full image size mode. A simple click on the image returns the  box to its compact state.&quot;</p>
<p><a href="http://herr-schuessler.de/blog/jquerypopeye-an-inline-lightbox-alternative/" class="smallbox">Visit site</a></p>
<h2>DD_roundies</h2>
<p>An easy way to implement round corners in IE. </p>
<p>&ldquo;No 9-cell tables for one round box. No images. Doesn&#8217;t add a half-dozen or more HTML nodes to a container element (more like one, maximum of two, and only in IE).&rdquo; </p>
<p><a href="http://dillerdesign.com/experiment/DD_roundies/" class="smallbox">Visit site</a></p>
<h2>Niceforms</h2>
<p><strong>&ldquo;</strong>Niceforms is a script that will replace the most commonly used form  elements with custom designed ones. You can either use the default  theme that is provided or you can even develop your own look with  minimal effort.&rdquo;</p>
<p><a href="http://www.emblematiq.com/projects/niceforms/" class="smallbox">Visit site</a></p>
<h2>jQuery Corners 0.3</h2>
<p>&ldquo;This jQuery plugin will easily create beautifully rounded corners.            No images or obtrusive markup necessary.&rdquo;</p>
<p> Another round corner script for your benefit! </p>
<p><a href="http://www.atblabs.com/jquery.corners.html" class="smallbox">Visit site</a></p>
<h2>Superfish jQuery menu plugin</h2>
<p>&ldquo;Superfish is an enhanced Suckerfish-style menu jQuery plugin that takes  an existing pure CSS drop-down menu (so it degrades gracefully without  JavaScript) and adds the following much-sought-after enhancements.&rdquo;</p>
<p><a href="http://users.tpg.com.au/j_birch/plugins/superfish/" class="smallbox">Visit site</a></p>
<h2>JavaScript Will Save Us All</h2>
<p>Eric Meyer&#8217;s opinion on why we should look to JavaScript to extended standard support badly lacking in many browsers, instead of waiting for the browser vendors to implement them.</p>
<p><a href="http://meyerweb.com/eric/thoughts/2008/10/22/javascript-will-save-us-all/" class="smallbox">Visit site</a></p>
<h2>CSS Sprites2 &#8211; It&#8217;s JavaScript Time</h2>
<p>&ldquo;A sense of movement is often the differentiator between Flash-heavy web  sites and standards-based sites. Flash interfaces have always seemed  more alive&mdash;responding to the user&#8217;s interactions in a dynamic way that  standards-based web sites haven&#8217;t been able to replicate. Lately that&#8217;s been changing, of course, with a resurgence in dynamic  interface effects, helped along by JavaScript libraries that make it  easy&mdash;libraries such as Prototype, Scriptaculous, Moo, YUI, MochiKit (and I could go on). It&#8217;s high time to revisit the CSS Sprites technique from four years ago, and see if we can&#8217;t interject a little bit of movement of our own.&rdquo;</p>
<p><a href="http://alistapart.com/articles/sprites2" class="smallbox">Visit site</a></p>
<h2>jParallax</h2>
<p>&ldquo;jParallax turns a selected element into a &#8216;window&#8217;, or viewport, and  all its children into absolutely positioned layers that can be seen  through the viewport. These layers move in response to the mouse, and,  depending on their dimensions (and options for layer initialisation),  they move by different amounts, in a parallaxy kind of way.&rdquo;</p>
<p>Pure joy! </p>
<p><a href="http://webdev.stephband.info/parallax.html" class="smallbox">Visit site</a></p>
<h2> Fixed Footers without JavaScript</h2>
<p>A pure CSS technique to position fixed footers, tested down to IE 5.5. </p>
<p><a href="http://boagworld.com/technology/fixed_footers_without_javascri/" class="smallbox">Visit site</a></p>
<h2>Dynamic Layout</h2>
<p>&ldquo;Dynamic Layout is a simple JavaScript library that allows you to easily adjust page layout based on the current browser width.&rdquo;</p>
<p><a href="http://fortes.com/projects/dynamiclayout/" class="smallbox">Visit site</a></p>
<h2>Stop using Ajax!</h2>
<p>&ldquo;Ajax is a sound and useful idea. But every idea comes down to a  practical implementation &#8211; a technology that makes it happen &#8211; and in  this case the technology is immature, because it  leaves groups of users behind. Most notable and greatly affected are  those using assistive technologies, but also those using less capable  browsers that don&#8217;t support the necessary scripting objects, or don&#8217;t  support scripting at all. &rdquo;</p>
<p><a href="http://dev.opera.com/articles/view/stop-using-ajax/" class="smallbox">Visit site</a></p>
<h2>This is how you get sIFR to work</h2>
<p>&ldquo;The goal of this tutorial is to distill the information at the official site for sIFR into a simple step-by-step process of how to implement sIFR on your site.</p>
<p>After following this tutorial you will have a basic understanding of how sIFR works and will be able to expand into more advanced areas.&rdquo;</p>
<p><a href="http://designintellection.com/2008/this-is-how-you-get-sifr-to-work/" class="smallbox">Visit site</a></p>
<h2> FancyZoom</h2>
<p>Smooth Javascript Image Zooming For Your Web Pages.&nbsp;</p>
<p><a href="http://www.cabel.name/2008/02/fancyzoom-10.html" class="smallbox">Visit site</a></p>
<h2>Rotating 3D cube in JavaScript </h2>
<p>Nothing more, nothing less! Check it out. </p>
<p><a href="http://maettig.com/code/javascript/3d_dots.html" class="smallbox">Visit site</a></p>
<h2>Super Mario in 14kB Javascript</h2>
<p><strong>&ldquo;</strong>Here&#8217;s an experiment in keeping things small and confined to one  Javascript file. There are no external image files or anything,  everything is rendered with Javascript using either canvas elements or  old fashioned div-making tactics (for IE). The sprites are stored in  custom encoded strings in a format that only allows 4 colors for each  sprite but in turn only takes up around 40-60 bytes per sprite.<strong>&rdquo;</strong></p>
<p><a href="http://blog.nihilogic.dk/2008/04/super-mario-in-14kb-javascript.html" class="smallbox">Visit site</a></p>
<h2>10 Smart Javascript Techniques to Improve Your UI</h2>
<p>&ldquo;Javascript is typically used as an aesthetic language in web  development. This means that web developers should almost always be  using Javascript for one thing only: Improving the visitor&#8217;s experience.  There are many clever and useful ways to improve a site from the user  interface perspective. A developer can find nearly any snippet of  Javascript to achieve what he or she wants to accomplish.&rdquo;</p>
<p><a href="http://nettuts.com/javascript-ajax/10-rare-but-clever-javascript-techniques/" class="smallbox">Visit site</a></p>
<h2>25 Amazing JavaScript Games (Some Fun And Inspiration)</h2>
<p>&ldquo;JavaScript, with the rise of Ajax, is definitely a must-know-well for every web designer/developer.</p>
<p>Besides form controls, alerts &#038; similar simple JavaScript usage, you can almost do anything with the help of JavaScript (&#038; Canvas).&rdquo;</p>
<p><a href="http://www.webresourcesdepot.com/25-amazing-javascript-games-some-fun-and-inspiration/" class="smallbox">Visit site</a></p>
<h2>Top 5 Favorite Bookmarklets</h2>
<p>&ldquo;Bookmarklets are the JavaScript-enabled links you can pull into your  bookmarks that interact with whatever page you find yourself on. The  best bookmarklets act as you would typically expect a toolbar to, by  extending your browsing experience. However, since they&rsquo;re written in  JavaScript, they all by working within the browser and without  requiring installation. Here are 5 highly recommended bookmarklets you can drag to your  browser&rsquo;s toolbar or to your bookmarks to extend your browsing  experience.&rdquo;</p>
<p><a href="http://www.webmonkey.com/blog/Top_5_Favorite_Bookmarklets" class="smallbox">Visit site</a></p>
<h2>10 Promising JavaScript Frameworks</h2>
<p>&ldquo;Popular JavaScript frameworks/libraries like jQuery,  MooTools, Prototype, and YUI (to name a few of the <a href="http://royal.pingdom.com/?p=305" title="Royal Pingdom - Javascript framework usage among top websites">most  popular JavaScript frameworks out there</a>)  definitely have a solid foothold in the JavaScript framework arena. But  for the more adventurous developers looking for new or alternative  frameworks/libraries &ndash; there are some excellent frameworks outside the  popular ones that&rsquo;s worth checking out.&rdquo;</p>
<p><a href="http://sixrevisions.com/javascript/promising_javascript_frameworks/" class="smallbox">Visit site</a></p>
<h2>5 Useful Coding Solutions For Designers and Developers</h2>
<p>	  &ldquo;Often creative and truly remarkable design solutions remain unknown because we, designers, simply overlook them. Being busy  with our own projects, we sometimes try to grasp the intuition behind  (probably) complex and cluttered code of other designers to understand  how they manage to implement particular design ideas. In fact, by just  observing the code of other developers we can learn a lot from them; we  can find interesting ideas and improve the quality of our work.&rdquo;</p>
<p><a href="http://www.smashingmagazine.com/2008/08/11/5-useful-coding-solutions-for-designers-and-developers/" class="smallbox">Visit site</a></p>
<h2>Calling WebServices via AJAX </h2>
<p>This tutorial will give you a good idea of how to use JavaScript to interact with WebServices. </p>
<p><a href="http://blogs.msdn.com/kaevans/archive/2008/04/03/calling-webservices-via-ajax-part-1.aspx" class="smallbox">Visit site</a></p>
<h2> JavaScript Pretty Date</h2>
<p>&ldquo;&#8230; A simple way to format old JavaScript dates in a &quot;pretty&quot; way. &rdquo;</p>
<p><a href="http://ejohn.org/projects/javascript-pretty-date/" class="smallbox">Visit site</a></p>
<h2> JavaScript iPhone Apps</h2>
<p>	  I&#8217;ve been watching, with interest, developers create new applications  for the iPhone. Owning one myself &#8211; and being knowledgeable in  JavaScript &#8211; I&#8217;ve been wondering what options there were for creating  downloadable JavaScript applications or the iPhone. In doing some  research I found a number of solutions, some simpler than others, some  requiring more knowledge of Objective-C than others. &rdquo;</p>
<p><a href="http://ejohn.org/blog/iphone-javascript-apps/" class="smallbox">Visit site</a></p>
<h2>Most Wanted Ajax Techniques: 50+ Examples and Tutorials </h2>
<p>	  Web applications have made huge leaps and bounds in improving user  experience thanks to a lot of recently developed Ajax technology. When  you combine some neat functionality courtesy of PHP with the cleverness  of javascript you can produce some pretty cool results. In an effort to  help you take it up a notch, we&rsquo;d like to share some methods for  helping your site anticipate a user&rsquo;s next move.&rdquo;</p>
<p><a href="http://www.noupe.com/javascript/most-wanted-ajax-techniques-50-ajax-examples-and-tutorials.html" class="smallbox">Visit site</a></p>
<h2> 50 Excellent AJAX Tutorials</h2>
<p>	  AJAX provides Web developers with plenty of opportunities to enhance the user experience and improve the performance of their websites. There are countless ways that AJAX can be used, and fortunately there are plenty of good and useful AJAX tutorials out there to help you with your own implementation.</p>
<p>This post serves as a collection of useful tutorials on working with AJAX in a wide variety of ways. &rdquo;</p>
<p><a href="http://www.smashingmagazine.com/2008/10/16/50-excellent-ajax-tutorials/" class="smallbox">Visit site</a></p>
<h2>  10 things IT needs to know about Ajax</h2>
<p>	  The introduction of any new Web technology will affect a network&#8217;s infrastructure in ways that range from inconsequential     to earth shattering. Ajax is one of the more disruptive new Web technologies traveling across networks today. To help you     minimize future surprises on your network, we&#8217;ve outlined the 10 things you should take to heart about Ajax.  &rdquo;</p>
<p><a href="http://www.networkworld.com/research/2008/033108-ajax.html?nw" class="smallbox">Visit site</a></p>
<h2> jQuery timepickr </h2>
<p>	  <em>jquery.timepickr</em> was created in a attempt to make the process of inputing time in a form as                      easy and natural as possible.&rdquo;</p>
<p><a href="http://haineault.com/media/jquery/ui-timepickr/page/" class="smallbox">Visit site</a></p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/best-of-2008-javascript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Creating a Digg Style Sign Up Form</title>
		<link>http://designshack.net/articles/creating-a-digg-style-sign-up-form/</link>
		<comments>http://designshack.net/articles/creating-a-digg-style-sign-up-form/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 11:19:12 +0000</pubDate>
		<dc:creator>Janko Jovanovic</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[signup]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=137</guid>
		<description><![CDATA[Digg.com is one of the most popular social networking sites, allowing you to discover and share the content all over the web. In this tutorial we are going to simulate their signup form, with unique features such as their dynamic tooltips that give you a hint on each field that is to be filled. The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://digg.com/">Digg.com</a> is one of the most popular social networking        sites, allowing you to discover and share the content all over the web. In this tutorial we are going to simulate their signup form, with unique features such as their dynamic tooltips that give you a hint on each field that is to be filled. The same approach will be adopted for displaying validation messages.</p>
<p>
Before we get started, you may like to <a href="http://www.designshack.net/tutorialexamples/diggform/" target="_blank">view a demo</a> of the end result.
</p>
<h2>
        How this form works?</h2>
<p>
        When an input field receives focus, a tooltip with a small blue icon is shown under it.         On the other hand, if validation fails, an error message is shown in the same place. Both cases are shown on the screenshot below.</p>
<p>
        <img height="138" alt="digg-field" src="http://www.designshack.net/postimages/digg-field.png" width="539" border="0">
    </p>
<h2>
        Let&#8217;s start</h2>
<p>
        We are not going to recreate the entire form, but rather a few fields just to see        how it works. Let&#8217;s take a closer look at the code sample. Each field row has        a label, an input field, an info message and a validation message. Below you can see the        HTML structure and CSS classes.</p>
<p>
        Note that, by default, both info and validation messages are hidden, which is set        in tooltipContainer CSS class.</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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>“formContainer”&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>Join Now! It’s quick and easy.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h3</span>&gt;</span>
    <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>“rowContainer”&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span>“txtFirstname”&gt;</span>Choose a username<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span>“txtFirstname” <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span>“<span style="color: #000066;">text</span>” <span style="color: #66cc66;">/</span>&gt;</span>
        <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>“tooltipContainer info”&gt;</span>Minimum 4 characters, maximum 15 characters. This is your handle on Digg so don’t make it too personal.<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: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>“tooltipContainer error”&gt;</span>Rats! Username must be between 4 and 15 characters.<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>
   // other rows here
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span> 
&nbsp;
body{
    font-family:Arial, Sans-Serif;
    font-size:83%;
}
.formContainer
{
    background-color: #F5EFC9;
    border:none;
    padding:30px;
}
.formContainer h3
{
    margin:0px;
    padding:0px 0px 10px 0px;
    font-size:135%;
}
.rowContainer
{
    width:100%;
    overflow:hidden;
    padding-bottom:5px;
    height:34px;
}
.rowContainer label
{
    width:140px;
    float:left;
    color: #758656;
    font-weight:bold;
}
.rowContainer input[type=“text”]
{
    width:200px;
}
.tooltipContainer
{
    height:16px;
    font-size:11px;
    color: #666666;
    display:none;
    float:none;
    background-repeat:no-repeat;
    background-position:left center;
    padding:0px 20px;
}
.info
{
    background-image:url(‘info.gif’);
}
.error
{
    background-image:url(‘error.gif’);
}</pre></td></tr></table></div>

<h2>
        Now let&#8217;s add some interactivity</h2>
<p>
        So far we have a static HTML structure and hidden messages waiting to be shown.  We have to write a few lines of code to make them appear/disappear. Of course, this can be accomplished by pure JavaScript, but let&#8217;s involve jQuery. The reason for this is quite simple &#8211; less coding.</p>
<p>
        Like I mentioned at the beginning of this tutorial, an info tooltip should be shown        each time an input field gets focus and hidden when it loses it. Turn this into jQuery        code and you get this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td 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>
    $<span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">formContainer</span> input<span style="color: #009900;">&#91;</span>type<span style="color: #339933;">=</span>text<span style="color: #009900;">&#93;</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">info</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>“display”<span style="color: #339933;">,</span> “block”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">info</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>“display”<span style="color: #339933;">,</span> “none”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
        Simple, isn&#8217;t it? Now, let&#8217;s see how to handle validation messages. We are        going to create fake validation just for the purpose of this tutorial. We&#8217;ll        use jQuery again.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> validateForm<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: #660066;">formContainer</span> input<span style="color: #009900;">&#91;</span>type<span style="color: #339933;">=</span>text<span style="color: #009900;">&#93;</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><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> text <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>“value”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>text <span style="color: #339933;">==</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">error</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>“display”<span style="color: #339933;">,</span> “block”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
        In essence, what the code above does is it shows a validation message for each field        that the user hasn&#8217;t entered text in. Please keep in mind that this is not real validation,        it just simulates what would happen if validation failed. You would have to implement        your own logic, eg. check for mandatory fields, email address format and so        on.</p>
<p>
        Ok, after pressing the sign-in button, validation messages will be shown. Signup        form on Digg.com hides these messages and replaces them with info tooltips when the user        starts to type. So we are missing a piece of code that will hide validation messages        that were previously shown.</p>
<p>
        Let&#8217;s do it the dirty way. We&#8217;ll extend our jQuery code that controls the appearance        of tooltips to hide corresponding validation messages each time an input field gets        focus.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td 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>
    $<span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">formContainer</span> input<span style="color: #009900;">&#91;</span>type<span style="color: #339933;">=</span>text<span style="color: #009900;">&#93;</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">error</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>“display”<span style="color: #339933;">,</span> “none”<span style="color: #009900;">&#41;</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">info</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>“display”<span style="color: #339933;">,</span> “block”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span>”.<span style="color: #660066;">info</span>”<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>“display”<span style="color: #339933;">,</span> “none”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
        This way we have recreated the Digg.com signup form. You can check out <a href="http://www.designshack.net/tutorialexamples/diggform/" target="_blank">live demo</a>   or <a href="http://www.designshack.net/tutorialexamples/diggform/diggform.zip">download full source code</a>.</p>
<h2>
        Conclusion</h2>
<p>
        You saw how to recreate the Digg.com signup form with simple CSS and just        a few lines of jQuery code. However, there are a few pieces of advice I&#8217;d like to give you:</p>
<ul>
<li>Do not overwork the form &#8211; there is really no need for a tooltip that says &#8220;Enter            your first and last name in the field that says First and Last name&#8221;. Instead, you            can provide a message that shows a constraint, for example &#8220;Maximum 35 characters&#8221;.</li>
<li>Use tooltip/validation color other that text color &#8211; try hitting the &#8220;Continue&#8221; button            on Digg.com signup form before entering any text. The form becomes very hard to            read and it&#8217;s difficult to distinguish where one field ends and the next begins.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/creating-a-digg-style-sign-up-form/feed/</wfw:commentRss>
		<slash:comments>72</slash:comments>
		</item>
		<item>
		<title>Cross Browser Transparency</title>
		<link>http://designshack.net/articles/cross-browser-transparency/</link>
		<comments>http://designshack.net/articles/cross-browser-transparency/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 13:18:11 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[transparency]]></category>
		<category><![CDATA[transparent]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=448</guid>
		<description><![CDATA[There are many complicated methods to create transparency effects across the various browsers available (Firefox, Safari, Internet Explorer), but it can be simple to achieve this effect using a few CSS tricks. Albeit with a couple of limitations. Transparency rules Mozilla browsers can display transparency, using an effect specified through -moz-opacity: 0.5; where the value [...]]]></description>
			<content:encoded><![CDATA[<p>There are many complicated methods to create transparency effects across the various browsers available (Firefox, Safari, Internet Explorer), but it can be simple to achieve this effect using a few CSS tricks. Albeit with a couple of limitations.</p>
<h2>Transparency rules</h2>
<p>Mozilla browsers can display transparency, using an effect specified through <code>-moz-opacity: 0.5;</code> where the value is between 0 (completely transparent) and 1 (opaque).</p>
<p>Internet Explorer uses a <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/filter.asp">filter property</a> to allow you to show transparency. It takes the form <code>filter: alpha(opacity=50);</code> where the opacity value is between 0 and 100.</p>
<p>Some other browsers (and future browsers) will conform to the CSS3 specification allowing the property <code>opacity: 0.5;</code> with the value between 0 or 1 as with the Mozilla effect.</p>
<p>The way to get this working in all browsers is simply a matter of using all three rules at the same time:</p>
<pre>
#transparent-area {
	opacity: 0.5;
	-moz-opacity: 0.5;
	filter: alpha(opacity=50);
}
</pre>
<h2>Limitations</h2>
<p>The main problem with the above CSS code is that it is notoriously browser specific, and thus does not conform to valid CSS standards. This doesn&#8217;t stop it working correctly, but does mean that your CSS code won&#8217;t validate. </p>
<p>Also, as new browsers are released and updated you&#8217;ll need to alter the above. Hopefully as they adopt the CSS3 standard more strictly, simply using the <code>opacity: 0.5;</code> rule will suffice.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/cross-browser-transparency/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 631/752 objects using disk: basic

Served from: designshack.net @ 2012-02-10 00:19:30 -->
