<?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; css3</title>
	<atom:link href="http://designshack.net/tag/css3/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>Code an Awesome Animated Download Button With CSS3</title>
		<link>http://designshack.net/articles/css/downloadbutton/</link>
		<comments>http://designshack.net/articles/css/downloadbutton/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 06:00:43 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[download]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=28910</guid>
		<description><![CDATA[Follow along as we create a simple and fun download button using some fancy CSS3. Our button will use lots of fun goodies including border-radius, box-shadow, linear-gradients, z-index and transitions to achieve a unique double sliding drawer effect on hover. As we go, I&#8217;ll discuss why some techniques that you might think to use should [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-0.jpg" alt="screenshot" width="510"/></div>
<p>Follow along as we create a simple and fun download button using some fancy CSS3. Our button will use lots of fun goodies including border-radius, box-shadow, linear-gradients, z-index and transitions to achieve a unique double sliding drawer effect on hover. </p>
<p>As we go, I&#8217;ll discuss why some techniques that you might think to use should be avoided. Transitions are tricky to work with and are quite prone to refuse to work with certain properties. Read on to find out more. </p>
<p><span id="more-28910"></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>The Concept</h2>
<p>Loosely based on <a href="http://dribbble.com/shots/339317-Krazy-Download-Buttons-V2-1">this idea</a>, I wanted to create a download button with a cool sliding drawer effect where originally hidden information pops out when the user begins a hover event. To put my own spin on it, I decided to double the effect and create a drawer on both the top and bottom of the button (<a href="http://designshack.net/tutorialexamples/animatedDownload/index.html">click here</a> for a sneak peek of the finished result).</p>
<p>Here&#8217;s how it will work: using a combination of HTML and CSS, we&#8217;ll create three separate pieces. These include the main button and two smaller info panels. The smaller panels will initially hide under the larger button, then when the user hovers, one will slide upward and the other downward. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-1.jpg" alt="screenshot" width="510"/></div>
<p>As you can see, this will be a pretty easy project that is perfect for beginners that are looking to up their CSS skills. Especially worth learning is how we&#8217;ll utilize absolute positioning and stacking via z-index. </p>
<h2>What Won&#8217;t Work</h2>
<p>As I planned out this project, I came up with a couple of ways to make my concept work. Given that I&#8217;ve been on a <a href="http://designshack.net/articles/css/the-lowdown-on-before-and-after-in-css/">pseudo element</a> kick lately, the way that I chose to structure the project initially was through the use of :before and :after. </p>
<p>With these pseudo elements, we can code only the download button in our HTML and then add in the wings using pure CSS. It seems like an optimal solution and indeed it worked great&#8230; until I tried to animate the transition. No matter what I tried, I simply couldn&#8217;t get the transition to work.</p>
<p>After a little research I discovered that that only Firefox supports CSS transitions on pseudo elements. This is a real bummer that really limits the fun we can have with :before and :after, but on the upside I learned a valuable lesson that will save me a lot of time and trouble in the future.</p>
<p>In tutorials like this one you don&#8217;t often get to hear about where the author failed, but I think it&#8217;s important to communicate these failures so you can learn from them as I have. Now the next time you want to animate a pseudo element you&#8217;ll remember that it won&#8217;t work in most browsers!</p>
<p>Failures aside, let&#8217;s jump into a method that <em>will</em> work.</p>
<h2>The Button</h2>
<p>To begin, we&#8217;ll create and style our button. Once we have this in place, it&#8217;ll be easier to form the other elements. All we need in the HTML department is a single div containing a link. We could simply use the link for the button but we&#8217;ll need to group multiple objects together so a div is necessary.</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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span>&gt;</span>
  <span style="color: #009900;">&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>Download<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</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>Button Shape &#038; Size</h3>
<p>The HTML above should simply provide you with a plain text link. We&#8217;re going to transform this into a button with a set background shape and size. To do this, we start with some dimensions, add some color and set the display value to block.</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: #6666ff;">.button</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;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</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: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#00b7ea</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Here&#8217;s a look at what your button should look like after this step. It doesn&#8217;t look like much yet, but it&#8217;ll be a fancy looking button before you know it.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-2.jpg" alt="screenshot" width="510"/></div>
<h3>Type Styles</h3>
<p>The first ugly thing about the button above that we&#8217;ll need to fix is the type, it&#8217;s currently a mess. Fortunately, this is easy to address. All we need to do is set the color to white, declare a font, and center 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: #6666ff;">.button</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;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</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: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#00b7ea</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*TYPE*/</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">17px</span>/<span style="color: #933;">50px</span> Helvetica<span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</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;">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;">text-transform</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>There are a couple of interesting things to note here. First, notice that I&#8217;m using the &#8220;font&#8221; shorthand rather than running through reach font property individually. This is a great way to save space and keep your type styles nice and succinct. The order here is as follows:</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-3.jpg" alt="screenshot" width="510"/></div>
<p>Here&#8217;s another nifty trick: I set the line-height to 50px to center it vertically in the button. Also notice that I removed the text underline and transformed the type to be uppercase. Why didn&#8217;t I just type it out in all caps in HTML? Because this is really a style choice and could change with a future redesign. </p>
<p>Now our button is looking much better!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-4.jpg" alt="screenshot" width="510"/></div>
<h3>CSS3 Magic</h3>
<p>At this point our button is still looking a little plain. If you&#8217;re cool with the minimal look, you can skip ahead. Otherwise, let&#8217;s make it a little more interesting. The first thing we&#8217;ll do is round off the corners. Make sure you add all three browser prefixes:</p>
<div style="overflow: auto; background-color: #eeeeee;">

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

</div>
<p></ br></p>
<p>Next up, we&#8217;ll toss in a box-shadow. Once again, we&#8217;ll need three versions to cover the various browsers. The shorthand value order here is horizontal offset, vertical offset, blur and color.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
   -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>Finally, we&#8217;ll toss in a gradient. Unfortunately, this requires a whole mess of code. The way gradients work recently change so not only do we need multiple prefixes, we also need multiple syntaxes to make sure we support everything. I&#8217;m going to be honest, I rarely code this stuff by hand. Instead, I use the <a href="http://www.colorzilla.com/gradient-editor/">Ultimate Gradient Generator</a> and paste in the generated code. Here&#8217;s the result:</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: #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;">#00b7ea</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* FF3.6+ */</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> color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#00b7ea</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #933;">100%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Chrome,Safari4+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-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;">#00b7ea</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Chrome10+,Safari5.1+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -o-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;">#00b7ea</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Opera 11.10+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -ms-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;">#00b7ea</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE10+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> 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;">#00b7ea</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* W3C */</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.gradient<span style="color: #00AA00;">&#40;</span> startColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#00b7ea'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#009ec3'</span><span style="color: #00AA00;">,</span>GradientType<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE6-9 */</span></pre></div></div>

</div>
<p></ br></p>
<p>Now our button is completely styled and looking fine. Here&#8217;s the result:</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-5.jpg" alt="screenshot" width="510"/></div>
<h2>Adding The Drawers</h2>
<p>Now that our primary button is done, it&#8217;s time to add the little drawers that will slide out from the top and bottom (perhaps &#8220;wings&#8221; is the appropriate term). To do this, we&#8217;ll start by adding a little bit to our HTML:</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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span>&gt;</span>
  <span style="color: #009900;">&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>Download<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;</span>click to begin<span style="color: #009900;">&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: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;bottom&quot;</span>&gt;</span>1.2MB .zip<span style="color: #009900;">&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></pre></div></div>

</div>
<p></ br></p>
<p>As you can see, I basically tossed in two paragraphs, each with a unique class that makes them easy to target (you could use some pseudo selectors instead if you really want to get fancy).</p>
<h3>Default Paragraph Styling</h3>
<p>Now jump over to your CSS and we&#8217;ll style the paragraphs. To start, we want to focus on the styles that both paragraphs will share. Styling both at once where possible helps keep our code clean and less redundant. Here&#8217;s a big chunk of code to think over:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">180px</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-50px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*TYPE*/</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span>/<span style="color: #933;">45px</span> Helvetica<span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*POSITION*/</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> -<span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*CSS3*/</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
     -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
          border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
&nbsp;
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
     -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
          box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Now, this is a lot to throw at you all at once so I&#8217;ll walk through it step by step. The first thing we do is give the paragraphs shape, color and type styles exactly like we did on the button. The main difference is that these are smaller and use some margins to push them into place. </p>
<p>Next are the positioning styles. These are very important so be sure you understand them clearly. In order to make the wings appear behind the button, we need to apply z-index, which affects the stacking order of the elements. Think of this as a &#8220;send to back&#8221; sort of command. To make this work, we need to apply absolute positioning.</p>
<p>Finally, we added the same border-radius and gradient styles that we did before. I&#8217;ve kept these separated from the previous styles to keep things simple and clear, but to make things DRYer, you would probably want to rewrite your shared CSS3 styles to something like this:</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: #6666ff;">.button</span> a<span style="color: #00AA00;">,</span> p <span style="color: #00AA00;">&#123;</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
     -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
          border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
&nbsp;
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
     -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
          box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>      
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Basically, any time you find yourself repeating or pasting styles multiple times, you&#8217;re making your code unnecessarily complex and should attempt to simplify. </p>
<p>At the end of this step, you&#8217;ll strangely see no change in your preview from last time. This is because we&#8217;ve hidden these elements behind the button. They&#8217;re there, you just can&#8217;t see them yet!</p>
<h3>Hover and Active Styles</h3>
<p>What we want to do next is take the wings that we just created and move them outward when the user hovers over the button. To accomplish this, we simply need to adjust the margins on each paragraph. Here we target each of the classes that we created, then move the .top one up and the .bottom one down. The .top class also required a slight line-height adjustment to look right. </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: #6666ff;">.button</span><span style="color: #3333ff;">:hover </span>.<span style="color: #000000; font-weight: bold;">top</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-80px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</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;">35px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:hover </span>.<span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>While we&#8217;re here, we might as well throw some active styles on as well. These will take effect during a mouse down event.</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: #808080; font-style: italic;">/*Adjust Gradient*/</span>
<span style="color: #6666ff;">.button</span> a<span style="color: #3333ff;">:active </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;">#00b7ea</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Old browsers */</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;">#00b7ea</span> <span style="color: #933;">36%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* FF3.6+ */</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> color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #933;">36%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#00b7ea</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #933;">100%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Chrome,Safari4+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-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;">#00b7ea</span> <span style="color: #933;">36%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Chrome10+,Safari5.1+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -o-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;">#00b7ea</span> <span style="color: #933;">36%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* Opera 11.10+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -ms-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;">#00b7ea</span> <span style="color: #933;">36%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE10+ */</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> 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;">#00b7ea</span> <span style="color: #933;">36%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#009ec3</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* W3C */</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.gradient<span style="color: #00AA00;">&#40;</span> startColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#00b7ea'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#009ec3'</span><span style="color: #00AA00;">,</span>GradientType<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">0</span> <span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* IE6-9 */</span>
&nbsp;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Pulls in Wings*/</span>
<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:active </span>.<span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:active </span>.<span style="color: #000000; font-weight: bold;">top</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-70px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>As you can see, what I&#8217;ve done here is adjust the gradient so that the top color stretches a little farther, then I brought the wings back in a little bit so that there&#8217;s a contracting effect when you click. </p>
<p>Now our button is looking awesome. All three of our states are working. When you&#8217;re not hovering, it looks like a plain old button. When you are hovering, the wings or drawers pop out. When you click, the wings come in a little and the gradient changes ever so slightly. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-6.jpg" alt="screenshot" width="510"/></div>
<h2>Final Step: Add The Transition</h2>
<p>At this point, everything appears to be working just fine. The only problem is that the hover effect takes place instantly and of course we&#8217;d like it to be a little more gradual. To accomplish this, go back to your paragraph block and add in a basic 0.5 second transition using all of the required prefixes.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">180px</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-50px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*TYPE*/</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span>/<span style="color: #933;">45px</span> Helvetica<span style="color: #00AA00;">,</span> Verdana<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*POSITION*/</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> -<span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*CSS3*/</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
     -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
          border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
&nbsp;
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
     -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
          box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">8px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
  -webkit-transition<span style="color: #00AA00;">:</span> all 0.5s ease<span style="color: #00AA00;">;</span>
     -moz-transition<span style="color: #00AA00;">:</span> all 0.5s ease<span style="color: #00AA00;">;</span>
       -o-transition<span style="color: #00AA00;">:</span> all 0.5s ease<span style="color: #00AA00;">;</span>
      -ms-transition<span style="color: #00AA00;">:</span> all 0.5s ease<span style="color: #00AA00;">;</span>
          transition<span style="color: #00AA00;">:</span> all 0.5s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>With this addition, the button will transition very nicely between the three different states.</p>
<h2>See It In Action</h2>
<p>We&#8217;re all finished! You should now have an awesome animated CSS download button that is sure to impress. Check out the live demo below or <a href="http://tinkerbin.com/QfFHOSIL">check out the code on Tinkerbin</a>.</p>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/animatedDownload/index.html">Click Here to Launch</a></p>
<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/animatedDownload/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/anim-download-6.jpg" alt="screenshot" width="510"/></a></div>
<p>Want an even better version of the button with six different versions to choose from? Check out the awesome free download at our new sister site <a href="http://designcurate.com/resource/animated-download-button">Design Curate</a>.</p>
<h2>Conclusion</h2>
<p>Thanks for reading and following along. If you made it all the way through, pat yourself on the back for a job well done. </p>
<p>I hope you learned a thing or two about z-index or cool CSS3 tricks. If not, at least you got an awesome button out of the deal! Leave a comment below and let us know if you enjoyed the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/downloadbutton/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Nailing Browser Support in CSS3 and HTML5: Invaluable Resources to Use Today</title>
		<link>http://designshack.net/articles/css/nailing-browser-support-in-css3-and-html5-invaluable-resources-to-use-today/</link>
		<comments>http://designshack.net/articles/css/nailing-browser-support-in-css3-and-html5-invaluable-resources-to-use-today/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 17:23:23 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=28778</guid>
		<description><![CDATA[New technologies are making web development more exciting than ever before. HTML5 and CSS3 provide a double dose of modern practices that are absolutely refreshing and empowering. Unfortunately, utilizing these technologies can considerably complicate your quest for cross browser compatibility. How can you know which techniques are safe to use now and which you should [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-0.jpg" alt="screenshot" width="510"/></div>
<p>New technologies are making web development more exciting than ever before. HTML5 and CSS3 provide a double dose of modern practices that are absolutely refreshing and empowering. Unfortunately, utilizing these technologies can considerably complicate your quest for cross browser compatibility. </p>
<p>How can you know which techniques are safe to use now and which you should either provide alternatives to or avoid altogether? Join us as we take a look at a handful of our favorite resources that quickly and easily help you make informed decisions about real world HTML5 and CSS3 implementation. </p>
<p><span id="more-28778"></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>Simply Irresistible</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-10.jpg" alt="screenshot" width="510"/></div>
<p>Cross browser compatibility was difficult enough a few years ago before we started diving into fancy new technologies like HTML5 and CSS3. Now with these tools creeping to the forefront of our development methods, it can be a downright mess.</p>
<p>The benefits of using HTML5 and CSS3 are clear and undeniable. They&#8217;re so full of goodies and fun that nary one in ten developers can resist at least dipping a toe in to test the waters. To further the hype, authors like me are constantly dishing out awesome new tutorials that teach you the ins and outs of these technologies, thereby fueling your desire to put them into practice as soon as possible. </p>
<h2>Are We Rushing Ahead?</h2>
<p>While most of us are rushing headlong into utilizing the latest and greatest in web development trends, a few more rational souls are begging us to slow down. New toys are all well and good but much of this stuff is still under construction and the rest hasn&#8217;t been implemented well across all of the important browsers. </p>
<p>So who is right? How can you as a practical, real world developer know whether to buy into the hype and run with the new or trust the skeptics and stick with the tried and true methods from years past? </p>
<h2>Stop the Guesswork</h2>
<p>The single best thing that you can do to decide whether you can personally begin to implement new web technologies is to educate yourself on the support that you can expect for each new item in the various browsers that matter most to your audience. </p>
<p>This sounds like a lot of work doesn&#8217;t it? There are countless blogposts, books and websites dedicated to teaching you this stuff, enough to eat up an entire lifetime and more. The amount of material is so completely overwhelming that you might avoid learning simply out of intimidation.</p>
<p>Fortunately, there are some very easy and straightforward ways to make sure that what you&#8217;re doing will work well across various browsers. You won&#8217;t have to sort through mile long blog posts or read a stack of books every time you want to toss in a drop shadow, you&#8217;ll just need a quick look at a few select resources to get you going. </p>
<h2>Browser Compatibility Charts: A Developer&#8217;s Best Friend</h2>
<p>The very first thing that I recommend that you do in your quest to figure out which new technologies you can implement today is to bookmark one or two solid browser compatibility charts. </p>
<p>These resources are invaluable and can save you endless hours of research. They serve as a quick reference that immediately helps you identify which browsers do and don&#8217;t support the techniques that you&#8217;re trying to implement. Some of the better choices even offer help getting the older browsers to play nice. </p>
<h3><a href="http://caniuse.com/">When can I use&#8230;</a></h3>
<p><a href="http://caniuse.com/">Caniuse.com</a> is certainly not the prettiest option available for browser compatibility charts, but it is one of the most helpful and thorough.</p>
<div class="tutorialimage"><a href="http://caniuse.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-1.jpg" alt="screenshot" width="510"/></a></div>
<p>The organization here is very simple and easy to use: just click an item from any of the five categories (CSS, HTML5, SVG, JS API and Other) and you&#8217;ll be taken to a chart showing you the support for various browsers. Also, the search provides <em>instant results</em> as you type so answers to all your browser questions are never more than a few keystrokes away.</p>
<p>For instance, let&#8217;s say you read my <a href="http://designshack.net/articles/css/the-lowdown-on-before-and-after-in-css/">recent article on :before and :after</a> and would like to double check my statements about browser compatibility for the :after pseudo element (always double check your facts!), all you have to do is type &#8220;after&#8221; into the search bar and the chart below will pop up. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-2.jpg" alt="screenshot" width="510"/></div>
<p>There&#8217;s a ton of great information here for you to utilize. The chart informs us that we&#8217;ve got great support across the board for current browsers (even IE), but run into some trouble two versions back with IE7 and before. </p>
<p>In addition to the compatibility chart, you&#8217;ll find two other valuable items: a browser comparison feature and a list of helpful resources. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-3.jpg" alt="screenshot" width="510"/></div>
<p>The latter of these often includes some really great links. For instance, if you&#8217;re looking up new CSS3 functionality such as gradients, you might get a link for a generator that will do the work for you. In the case above we received a link for a detailed guide explaining the use of CSS generated content using pseudo elements. </p>
<p>The browser compatibility chart allows you to choose two browsers and see an overview of the support for the items in any of the five categories mentioned before.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-4.jpg" alt="screenshot" width="510"/></div>
<h3><a href="http://www.findmebyip.com/litmus/">FindMeByIP</a></h3>
<p>If you&#8217;re looking to forgo all of the features of the previous site in favor of some plain old extensive browser compatibility charts that you can bookmark and reference in a flash, check out the <a href="http://www.findmebyip.com/litmus/">HTML5 &#038; CSS3 Support page</a> at FindMeByIP. </p>
<div class="tutorialimage"><a href="http://www.findmebyip.com/litmus/"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-5.jpg" alt="screenshot" width="510"/></a></div>
<p>As you can see, the charts here are quite attractive and very easy to read. These are perfect for when you just need to quickly double check something or get an overview of browser support across the board. </p>
<h2>Should You Use It?</h2>
<p>Browser compatibility charts are awesome for letting you know whether or not a given browser supports what you&#8217;re trying to implement, but they only empower you to make decisions, you still have to interpret the information and decide whether or not it&#8217;s safe to proceed.</p>
<p>If you&#8217;re a new developer, this can be intimidating. To help you out further, be sure to check out <a href="http://html5please.us/">HTML5 Please</a>. This community sourced project  flat out tells you whether or not to use a given technique and makes recommendations for how to proceed. You should never follow something blindly, but when you&#8217;re on the fence this can sure help you make the call.</p>
<div class="tutorialimage"><a href="http://html5please.us/"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-6.jpg" alt="screenshot" width="510"/></a></div>
<p>As with <em>When Can I Use</em>, the search bar here provides instant results as you type. Let&#8217;s say you want to know whether or not CSS transitions are safe to implement, simply enter &#8220;transitions&#8221; and the results will filter to the following:</p>
<div class="tutorialimage"><a href="http://html5please.us/#transitions"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-7.jpg" alt="screenshot" width="510"/></a></div>
<p>Right away we get a recommendation for use, shown in the top right corner of the result:</p>
<div class="tutorialimage"><a href="http://html5please.us/"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-8.jpg" alt="screenshot" width="510"/></a></div>
<p>&#8220;Use with fallback&#8221; is the advice we are given for CSS transitions. This is coupled with some brief and straightforward information that tells us that transitions are safe if they&#8217;re not necessary for a usable experience and that any interaction critical transitions should be backed up with an alternative for other browsers. The necessary browser prefixes for implementation are also provided. For many items, recommended polyfills are provided to help make your implementation as cross browser compatible as possible. </p>
<h2><a href="http://www.modernizr.com/">Modernizr</a> Has Your Back</h2>
<p>The final resource you need to become familiar with in your quest for cross browser compatible CSS3 and HTML5 is <a href="http://www.modernizr.com/">Modernizr</a>. You&#8217;ve no doubt heard of it before, but it&#8217;s time to download it and check it out. </p>
<div class="tutorialimage"><a href="http://www.modernizr.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/compatibilitybuffer-9.jpg" alt="screenshot" width="510"/></a></div>
<p>The reason that Modernizr is so great is that it can automatically detect whether or not a browser supports a given feature and then serve up some JavaScript magic in response. This allows you to account for an impressively wide array of circumstances and provide JavaScript fallbacks and polyfills for older browsers with very little effort. </p>
<p>Modernizr will test for support for over 40 next-gen features, provide on the go information to tell you what will and won&#8217;t be supported and provides the best solutions around to help you respond to any holes in support.  </p>
<h2>Conclusion</h2>
<p>The resources above are all aimed at helping you make informed decisions about whether or not to implement a given HTML5 or CSS3 technique.</p>
<p>Browser compatibility charts provide a quick reference to how you can expect each browser to respond to a given technique, HTML5 Please will give you solid and honest recommendations for whether or not to proceed, and Modernizr will help you identify and fill the functionality gaps in a specific design. </p>
<p>These resources don&#8217;t get you off the hook for <a href="http://movethewebforward.org/">diving into deeper understanding</a> of how to properly implement these features, but they do serve as an awesome starting guide for how and when to proceed. </p>
<p>Leave a comment below and tell us about your favorite resources in this area. Do you use any of the sites listed above? What other tools are invaluable to your workflow?</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/nailing-browser-support-in-css3-and-html5-invaluable-resources-to-use-today/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Make It Snow on Your Website With CSS Keyframe Animations</title>
		<link>http://designshack.net/articles/css/make-it-snow-on-your-website-with-css-keyframe-animations/</link>
		<comments>http://designshack.net/articles/css/make-it-snow-on-your-website-with-css-keyframe-animations/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 06:00:10 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[let it snow]]></category>
		<category><![CDATA[make it snow]]></category>
		<category><![CDATA[snow]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=27674</guid>
		<description><![CDATA[The holiday season is at its peak and for some lucky people in weather appropriate climates, winter is in full swing. I live in Phoenix so real winter, and consequently snow, is really just a distant dream. Thus I am forced to turn to nerdery to get my fix! Today we&#8217;re going to go over [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/letitsnow/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/letitsnow-0.jpg" alt="screenshot" width="510"/></a></div>
<p>The holiday season is at its peak and for some lucky people in weather appropriate climates, winter is in full swing. I live in Phoenix so real winter, and consequently snow, is really just a distant dream. Thus I am forced to turn to nerdery to get my fix!</p>
<p>Today we&#8217;re going to go over a super simple CSS technique that you can use to make it snow on your website. It&#8217;ll only take you a few minutes at the most and it serves as a great introduction to using multiple background images and keyframe animations in CSS. </p>
<p><span id="more-27674"></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>Webkit FTW</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/letitsnow-1.jpg" alt="screenshot" width="510"/></div>
<p>To keep things simple, I&#8217;ll start off all of this code using the <em>-webkit</em> vendor prefix. This will keep our code cleaner and easier to read as we learn. The reason I chose Webkit is simple: the CSS keyframe animation support rocks. Even Firefox, which recently added keyframe support, really won&#8217;t cut it nearly as well as Safari. </p>
<p>Afterwards, we&#8217;ll discuss how to toss in the other vendor prefixes and what type of experience you can expect on each browser. Ultimately, if you&#8217;re really looking for a solidly supported effect that works on as many browsers as possible, I recommend seeking out a <a href="http://www.somethinghitme.com/2011/10/05/jquery-snowfall-1-5-update-now-with-snow-buildup/">jQuery snow plugin</a>. However, if you&#8217;re up for a fun CSS learning experience, keep reading! </p>
<h2>Getting Started: We Three PNGs</h2>
<p>The setup for this project is three snowy background images. You can definitely add more if you like, but we&#8217;ll use three here to keep things nice and simple. Basically, all you need is three transparent background PNG files of varying size with random little white dots on them.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/letitsnow-2.jpg" alt="screenshot" width="510"/></div>
<p>Here&#8217;s my process for setting these up. First, I created a 500px square image and used a tiny brush at full hardness. You can set up a scatter brush if you want but I like the control of manually placing the dots around the canvas. Then, to make sure it tiled nicely, I went to Filter>Other>Offset.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/letitsnow-3.jpg" alt="screenshot" width="510"/></div>
<p>Since I started with a 500px square image, I&#8217;m going to cut that in half and offset by 250px both horizontally and vertically. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/letitsnow-4.jpg" alt="screenshot" width="510"/></div>
<p>After you&#8217;ve run this command, you might have some messy spots near the center, these should be easy to clean up with a little erasing. The important part is that the edges wrap nicely so the middle of the image can be changed however you want.</p>
<p>Now save your PNG out and repeat this entire process for a 400px square image and a 300px square image. For these last two, I made the snowflakes a little blurrier and reduced the opacity a little. </p>
<h2>Applying the Backgrounds</h2>
<p>Now we&#8217;re going to apply these images to our background in CSS. I&#8217;m throwing them on using the body selector but feel free to apply them to something more specific. </p>
<p>Implementing multiple backgrounds is exactly like applying only one background, the only difference is that you throw in a comma after the first image URL and add in another. Here&#8217;s what our code will look like, note that the background images will all repeat by default.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#6b92b9</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow1.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow2.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow3.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Multiple backgrounds have great support across the board, the only real thing you have to worry about is, you guessed it, older versions of IE. As with just about everything else in advanced CSS, multiple backgrounds are supported in IE9, but nothing older than that. Hopefully the new IE auto update program will put an end to these types of woes!</p>
<h2>Setting Up the Keyframes</h2>
<p>In the past, we&#8217;ve done some <a href="http://designshack.net/?p=19905">decently complex keyframe animations</a> on Design Shack, but this time we can keep in really simple.</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;">@-webkit-keyframes snow {</span>
 <span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</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>
<p>Despite the fact that I&#8217;m referring to this as &#8220;simple&#8221; there&#8217;s admittedly a lot going on in this syntax so let&#8217;s break it down piece by piece. What this is doing is setting up an animation that we can then call into action elsewhere in our CSS. The base syntax is &#8220;@keyframes&#8221; but here we&#8217;re implementing the Webkit version so we used &#8220;@-webkit-keyframes&#8221;. The &#8220;snow&#8221; part is the name that I chose for the animation. You have some freedom here but try to choose something descriptive and helpful.</p>
<p>Next we initiate two frames. The first is what our page will look like at the beginning of our animation, the second is what it will look like at the end. At the beginning, I&#8217;ve placed all of our background images at the top left of the page using &#8220;0px 0px.&#8221; Then at the end, I&#8217;ve moved each image to a new location. Just like when we place each image, we&#8217;ll separate each set of position values with a comma.</p>
<h3>The Position Logic</h3>
<p>The position of each image at the end of the animation may seem arbitrary, but in reality this is very intentional. In order to make the animation work right, you have to understand a few things.</p>
<div class="pullquote-r">
&#8220;Once a single instance of an animation has run its course, it&#8217;s going to start over. If you don&#8217;t position your images properly, you&#8217;ll see a blip at this point.&#8221;
</div>
<p></ br></p>
<p>The reason we&#8217;re using keyframe animations instead of the simpler and much better supported transition property is because we can loop a keyframe animation endlessly so it will continue to snow indefinitely. With this in mind, you have to remember that once a single instance of an animation has run its course, it&#8217;s going to start over. If you don&#8217;t position your images properly, you&#8217;ll see a blip at this point.</p>
<p>The trick is to utilize the size of your images to make sure the end frame matches the beginning frame, thus creating a seamless transition. For instance, my second background image was 400px by 400px, so I moved the background 400px down during the course of the animation, the same for my third image at 300px. For my first image I did something a little different. I wanted it to move faster so I doubled the height and moved it 1,000 pixels. Since this is a multiple of the height, the last frame will still match the first.</p>
<p>Also notice that I moved the horizontal position of the images as well. This adds a bit of wind into the equation so the snow isn&#8217;t falling perfectly vertically. If you want the snow to sway back and forth as it falls, simply add in a few more frames. </p>
<h2>Implementing the Animation</h2>
<p>Our final step is to return to the body selector and throw in &#8220;-webkit-animation&#8221; to create an instance of the animation. First we state the name of the animation that we want to use, in this case &#8220;snow,&#8221; then we state the duration of the animation (20 seconds), next we choose a timing function (linear) and finally we loop the animation infinitely. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#6b92b9</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow3.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow2.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-animation<span style="color: #00AA00;">:</span> snow 20s linear infinite<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>With that, your website should be snowing like crazy in Safari! Let&#8217;s take a look at expanding this a little.</p>
<h2>Other Browser Prefixes</h2>
<p>Now to add more browser support. Our keyframe setup section should be expanded to the following. I&#8217;ve started with the base syntax without a browser prefix, then used the prefixes for Mozilla, Webkit and Microsoft. </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: #808080; font-style: italic;">/*Keyframes*/</span>
<span style="color: #a1a100;">@keyframes snow {</span>
 <span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@-moz-keyframes snow {</span>
 <span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@-webkit-keyframes snow {</span>
<span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@-ms-keyframes snow {</span>
 <span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</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>
<p>Then we do the same for the styles in the body. All of the various browsers use the same syntax, only the prefix changes.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#6b92b9</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow2.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'snow3.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	-webkit-animation<span style="color: #00AA00;">:</span> snow 20s linear infinite<span style="color: #00AA00;">;</span>
	-moz-animation<span style="color: #00AA00;">:</span> snow 20s linear infinite<span style="color: #00AA00;">;</span>
	-ms-animation<span style="color: #00AA00;">:</span> snow 20s linear infinite<span style="color: #00AA00;">;</span>
	animation<span style="color: #00AA00;">:</span> snow 20s linear infinite<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Note that the IE support here is purely for the future. Only IE 10 has support for keyframe animations and its still under development. </p>
<h2>&#8220;Not So Fast&#8221; says Firefox</h2>
<p>At this point I wanted to be all done with the tutorial, but alas, I opened up Firefox and found a problem: no animation! After some digging it turned out that the problem is in the multiple background implementation. </p>
<p>The issue is a strange one. Firefox supports multiple background images and it supports keyframe animations. It even supports animations that use multiple background images! However, for some reason it doesn&#8217;t seem to support moving each background image&#8217;s position independently during a keyframe animation.</p>
<h3>Update</h3>
<p>Great news, commenter Patric solved our little Firefox problem! It turns out my love for shorthand got me into trouble here. Firefox works perfectly if you list out all of the values in the initial line. Here&#8217;s the updated keyframe code:</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: #808080; font-style: italic;">/*Keyframes*/</span>
<span style="color: #a1a100;">@keyframes snow {</span>
<span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@-moz-keyframes snow {</span>
<span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@-webkit-keyframes snow {</span>
<span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">50%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#b4cfe0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</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;">#6b92b9</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@-ms-keyframes snow {</span>
<span style="color: #933;">0%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
 <span style="color: #933;">100%</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span> <span style="color: #933;">1000px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">400px</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">,</span> <span style="color: #933;">300px</span> <span style="color: #933;">300px</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>
<h2>See It in Action</h2>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/letitsnow/index.html">Click here</a> to launch</p>
<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/letitsnow/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/letitsnow-0.jpg" alt="screenshot" width="510"/></a></div>
<h2>Conclusion</h2>
<p>To sum up, making a pure CSS looped snow animation that works in modern browsers is a snap. A few minutes of Photoshop and a couple of simple lines of code and you&#8217;ve got the North Pole. IE won&#8217;t support keyframe animations until version 10, Opera currently has zero support and Firefox has support, but it&#8217;s not as extensive as what you&#8217;ll find in Webkit. </p>
<p>This project perfectly illustrates why it&#8217;s important to play around with this stuff before it&#8217;s ready to be implemented in the real world. I had no idea that Firefox would throw a wrench into my little animation until I actually got my hands dirty with an experiment. Now I find myself much more educated on the necessary syntax for CSS animations on a browser to browser basis. </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/make-it-snow-on-your-website-with-css-keyframe-animations/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Design an iPhone App Website Template With E-Mail Signup</title>
		<link>http://designshack.net/articles/javascript/design-an-iphone-app-website-template-with-e-mail-signup/</link>
		<comments>http://designshack.net/articles/javascript/design-an-iphone-app-website-template-with-e-mail-signup/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 14:15:09 +0000</pubDate>
		<dc:creator>Jake Rocheleau</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[mailchimp]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=24688</guid>
		<description><![CDATA[If you&#8217;ve been on the scene with iOS then you&#8217;ve surely seen some of the beautiful app websites cropping up. These have been released over the past couple of years as developers have been looking for ways to attract marketing potential. There are a lot of very standard-looking templates out there for web designers &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been on the scene with iOS then you&#8217;ve surely seen some of the beautiful app websites cropping up. These have been released over the past couple of years as developers have been looking for ways to attract marketing potential. There are a lot of very standard-looking templates out there for web designers &#8211; but my hope is to tackle something new!</p>
<p>Today we&#8217;ll be creating a styled iPhone App website template using HTML5/CSS3. This will not be targeted onto a specific app, so we don&#8217;t include a download link to the app store. Instead I&#8217;ve created a small e-mail signup form through MailChimp so you can hook early adopters into the app for pre-release. This is great for developers who need to get something up and running for their product before it&#8217;s on the market.</p>
<p><span id="more-24688"></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 style="text-align:center"><strong><a href="http://designshack.net/tutorialexamples/iphoneapp/index.html">View Live Demo</a></strong> &#8211; <strong><a href="http://designshack.net/tutorialexamples/iphoneapp/iphone-app-website-template-demo-source.zip">Download Source</a></strong></p>
<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/iphoneapp/index.html" target="_blank"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/app-template-signup-demo.jpg" alt="iPhone Application Website Template Demo" width="510" /></a></div>
<p>However, if you&#8217;ve noticed the app screenshot I&#8217;m using is from an actual app. It&#8217;s called <a href="http://itunes.apple.com/app/balllin-dribbble-for-iphone/id457288487?mt=8">Ballin ~ Dribbble for iPhone</a> and just popped into the store a few weeks ago. This layout isn&#8217;t used to condone the Ballin app, instead I just needed a screenshot to include for demo purposes. But feel free to use another screen if you copy the template for your own website.</p>
<h2>Getting Started</h2>
<p>As always we start off with some very simple HTML page structure. If you checked out the demo everything we need is centered in the page and aligned properly. The code isn&#8217;t convoluted at all! I&#8217;m using the standard HTML5 doctype with 3 external files included.</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&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&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>iPhone App Website with E-mail Signup<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;">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;global.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.6.2/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;http://downloads.mailchimp.com/js/jquery.form-n-validate.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: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></pre></div></div>

</div>
<p>The first is our global.css styles in an alternate file. Second we need the latest jQuery library hosted through Google Code databases. And finally I&#8217;ve added the form validation script from MailChimp. This script tag is normally copied over into your body area with the e-mail signup form, but to simplify the code I&#8217;ve moved it into the head.</p>
<p>So now let&#8217;s focus on parts of the body. I will skip over our e-mail signup just for now so we can focus on the bare-bones styles and framework. After opening the body you&#8217;ll notice an ID <code>#iphone-preview</code> which is used to house the Ballin&#8217; app iPhone screenshot. We&#8217;re actually using only two images in this webpage &#8211; the iPhone screen and our blue gradient background.</p>
<p>Also as a quick note I&#8217;ve used an iPhone 4 PSD file for creating the graphic. You can check it out at the <a href="http://macristocracy.com/vanilla/comments.php?DiscussionID=1126">Macristocracy blog</a> where Jake Moore has offered the free PSD for download. Or alternatively just download directly <a href="http://cl.ly/1JRk">from his CloudApp link</a> without visiting the page!</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;">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;iphone-preview&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrap&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;img/ballin-app.png&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Ballin' App Preview&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;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main-content&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrap&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>sign up below for instant e-mail updates and early <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">em</span>&gt;</span>beta access<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">em</span>&gt;</span> in the app store!<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span></pre></div></div>

</div>
<p>Now below the iPhone we have an ID <code>#main-content</code> which is similarly given a class of wrap. This means the content will be centered on our page regardless of resolution size. Inside the h2 tag I nested an em for emphasis on the words <strong>beta access</strong>. Using CSS I styled the em element to give a light pink coloring so these will stand out much more! Everything else is focusing on our e-mail signup, so let&#8217;s jump into global.css to clarify a few points quickly.</p>
<h2>Designer&#8217;s CSS Code</h2>
<p>In my source files the global.css is located directly in the root with index.html. I&#8217;ve grouped my styles into three main categories &#8211; global elements, body structure, and e-mail form styles.</p>
<p>Inside the core body I&#8217;ve added code for our wrapper class and to position the iPhone graphic. Each wrapper is contained within 660 pixels and centered horizontally on the page. Additionally the container div around our iPhone image is given a bottom border with the hex color #b4ada8. If you&#8217;ve noticed I chose to style this piece similarly to <a href="http://oink.com/">Milk&#8217;s Oink App</a> for iOS.</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: #808080; font-style: italic;">/* @group core body */</span>
<span style="color: #cc00cc;">#iphone-preview</span> <span style="color: #00AA00;">&#123;</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;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#b4ada8</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;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#iphone-preview</span> img <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;">margin-bottom</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: #6666ff;">.wrap</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;">660px</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>They use an outer glow on the iPhone and have matched colors for their app. Also, they&#8217;re using jQuery for a fade-in effect which I chose not to include. But this is a wonderful teaser layout to keep your visitors interested and begging for more info!</p>
<h2>Setting Up MailChimp</h2>
<p>This is the piece where things start to get a bit confusing. MailChimp includes a lot of their own custom code when you go to create a form. I actually had to edit out a lot of meaningless stuff from their generic code block &#8211; so don&#8217;t get discouraged if you can&#8217;t match up your styles exactly the same. My code will work 100% if you change both of the list subscription URLs generated automatically through MC.</p>
<p>So to get started head over into MailChimp and login. If you don&#8217;t have an account signup is totally free for under 12k e-mails/month (which is pretty realistic). After you log into the Dashboard look for a link at the top titled &#8220;Lists&#8221;. These are used to manage your subscribers for a specific topic &#8211; and this is how MailChimp will create your unique signup form tied into a list set. Create a new list, give it a quick name, and we should be set to go.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/mailchimp-lists-signup-embed.jpg" alt="MailChimp Screenshot for Lists Signup" width="510" /></div>
<p>Once in the List Dashboard area you should notice a set of sub-navigation links. On the far right you&#8217;ll notice For Your Website and in the drop-down menu click <strong>Signup Form Embed Code</strong>. This is the code you&#8217;ll need to embed for a small signup form using MailChimp.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/mc-classic-signup-embed-code.jpg" alt="MailChimp Embed Code for Classic Form" width="510" /></div>
<p>In the left-hand menu select <strong>Classic Form</strong> and customize the features to your liking. I&#8217;ve removed the title and just kept a standard e-mail field for signup. The code you need to copy is in the box below&#8230; so now we can go ahead and move on with our custom edits.</p>
<h2>Customizing the Signup Form</h2>
<p>Start out by removing the top style tag with all of their custom CSS edits. It&#8217;s nice they offer this, but we really don&#8217;t need it. Next if you look for the form element you&#8217;ll notice a very long URL in the action=&#8221;" attribute. This is one of the two custom URLs which will match up to your list. If you copy over from my code make sure to replace the form action with <strong>your own list URL</strong> &#8211; otherwise visitors will be signing up into my site!</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: #808080; font-style: italic;">&lt;!-- Begin MailChimp Signup Form --&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;mc_embed_signup&quot;</span>&gt;</span> 
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://destinyislands.us2.list-manage.com/subscribe/post?u=8329c77b379de0413725b5380&amp;amp;id=9d70a869e7&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mc-embedded-subscribe-form&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mc-embedded-subscribe-form&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;validate&quot;</span> <span style="color: #000066;">target</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;_blank&quot;</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;mce-responses&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;response&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mce-error-response&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display: none;&quot;</span>&gt;&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><span style="color: #ff0000;">&quot;response&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mce-success-response&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display: none;&quot;</span>&gt;&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> 
&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;mc-field-group&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mcform-fields-group&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">center</span>&gt;&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;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;required email&quot;</span> placeholder<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Email address...&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mce-EMAIL&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">center</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;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Subscribe&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;subscribe&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btn&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: #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></pre></div></div>

</div>
<p>Above is an example of what my form looks like after gutting all the MailChimp nonsense. It still contains a lot of the original code, but I&#8217;ve moved the error messages above the main input field. Also using the HTML5 <strong>placeholder</strong> attribute we can add default text into the e-mail field input before a user clicks.</p>
<p>Now the script tag is where people tend to get lost. If you notice two scripts you should check if one of them is the jQuery form validate.js file. If so you can remove it since we&#8217;ve already included this in our header. All of the other code is really used for checking if the form has been filled out properly. It&#8217;s very convoluted if you don&#8217;t understand jQuery, but luckily you don&#8217;t need to edit much of anything in here. If you copy the JS from my demo vs downloading from MailChimp you may experience differences if they have updated the backend since this publication. To play it safe just try working off my demo for now.</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: #003366; font-weight: bold;">var</span> mce_validator <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mc-embedded-subscribe-form&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">validate</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://destinyislands.us2.list-manage2.com/subscribe/post-json?u=8329c77b379de0413725b5380&amp;amp;id=9d70a869e7&amp;amp;c=?'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'GET'</span><span style="color: #339933;">,</span> dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'json'</span><span style="color: #339933;">,</span> contentType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;application/json; charset=utf-8&quot;</span><span style="color: #339933;">,</span></pre></div></div>

</div>
<p>I do want to bring your attention to one final important aspect of the JavaScript code. The options variable is used to pass information to the Ajax call when checking for validation. You&#8217;ll notice another subscription URL in the jQuery, but if you have a keen eye you should notice this isn&#8217;t the same URL as before!</p>
<p>It&#8217;s very important that you have both of these URLs set properly. The form action calls a URI with <strong>/subscribe/post</strong> while the jQuery URL is calling <strong>/subscribe/post-json</strong>. Even if you copy/paste from my demo just updating these two URLs with your own will be enough to get the script working for you.</p>
<p style="text-align:center"><strong><a href="http://designshack.net/tutorialexamples/iphoneapp/index.html">View Live Demo</a></strong> &#8211; <strong><a href="http://designshack.net/tutorialexamples/iphoneapp/iphone-app-website-template-demo-source.zip">Download Source</a></strong></p>
<h2>Conclusion</h2>
<p>This has been a fast-paced introduction to setting up an iOS App website using MailChimp. We&#8217;ve downloaded an iPhone PSD from the Internet and setup a small application graphic. We&#8217;ve also utilized some basic jQuery and CSS3 modeling to create a fantastic e-mail signup form using Ajax. And with all of this tied into MailChimp you&#8217;re getting a great subscription service totally free.</p>
<p>Let us know your thoughts or questions in the comments area below. Additionally if you implement the tutorial code anywhere we would love to see it live! Include a link to your web page if you&#8217;ve set up a similar iPhone or iPad app template design.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/javascript/design-an-iphone-app-website-template-with-e-mail-signup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing a Digg-Style Input Form With CSS3 and jQuery</title>
		<link>http://designshack.net/articles/javascript/developing-a-digg-style-input-form-with-css3-and-jquery/</link>
		<comments>http://designshack.net/articles/javascript/developing-a-digg-style-input-form-with-css3-and-jquery/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 19:03:37 +0000</pubDate>
		<dc:creator>Jake Rocheleau</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=23115</guid>
		<description><![CDATA[Digg is one of the most popular social news networks to date. They garner a massive audience in the millions of members. Recently the company has carved a new direction with the launch of Digg v4. The entire system has been replaced with new statistics and followers/following networking. One of the most notable changes is [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/digg-input-form.jpg" alt="Digg form with CSS3 and jQuery" width="510" /></div>
<p>Digg is one of the most popular social news networks to date. They garner a massive audience in the millions of members. Recently the company has carved a new direction with the launch of Digg v4. The entire system has been replaced with new statistics and followers/following networking.</p>
<p>One of the most notable changes is in page aesthetics. With the launch of Digg v4 boasts a brand new design with a unique look and feel. In this tutorial I&#8217;ll be going over how you can create your own Digg v4 style input form using some basic CSS3 properties.</p>
<p><span id="more-23115"></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>
<p>We&#8217;ll also be using jQuery to manipulate each of the key divisions for a nifty animation effect. We won&#8217;t be using any fancy Ajax calls here, although jQuery does support such functionality. The main form we&#8217;ll be using is based off Digg&#8217;s current submit page.</p>
<p><strong><a href="http://designshack.net/tutorialexamples/DiggJake/index.html">Live Demo</a> &#8211; <a href="http://designshack.net/tutorialexamples/DiggJake/digg-v4-input-form.zip">Download</a></strong></p>
<h2>Working with CSS3 and jQuery</h2>
<p>As it may not be implied, there isn&#8217;t anything special required to work with CSS3. We don&#8217;t need to include any external files or libraries since most modern browsers will support a newer rendering engine. jQuery does have to be included into our file. Lucky for us Google Code hosts all versions of popular scripts online.</p>
<p>Using the Google APIs docs we can start working with jQuery 1.4.1. I&#8217;ve included the minified version to save bandwidth in the long run (always a good idea for production environments). Aside from this we&#8217;ll also need our core files. In order this will include a simple index.html, global.css for styles and script.js for our jQuery functionality.</p>
<h2>Bare Structures</h2>
<p>We can first start with our HTML code. It should be fairly straightforward but it doesn&#8217;t hurt to break things down into sections.</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>Digg-Style Input Forms<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;">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;global.css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;all&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;script.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>This is the main heading portion of our HTML document. It contains all meta information along with an XHTML transitional doctype.  The only file inclusions we&#8217;re working with are CSS and external JavaScript code. Both of these files are stored locally while our jQuery map is included via <a href="http://ajax.googleapis.com/">http://ajax.googleapis.com/</a>.</p>
<p>Next we have some basic code for our core body layout. This will include the Digg heading and logo portion of the page. This also includes our small form with a few input buttons and div boxes.</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;">body</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;header-wrapper&quot;</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;header group&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sprite digg-logo&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header-logo&quot;</span>&gt;</span>Digg<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;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&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;page-wrapper group&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;column full group&quot;</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Submit to Digg<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</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;submission-form-container&quot;</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;flexible-input&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submission-url-row&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;submission&quot;</span> placeholder<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit a link&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text-input&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url-submit-url&quot;</span> <span style="color: #000066;">value</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;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submission-editor-wrapper&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display:block;&quot;</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;submission-editor&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;group&quot;</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;submission-detail-field&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edit-input&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edit-title&quot;</span>&gt;</span>Edit<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit-title&quot;</span>&gt;</span>Destiny Islands Blog<span style="color: #009900;">&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: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flexible-input&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;submission-title&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Destiny Islands Blog&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text-input&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;user-title-text&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>
        <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;submission-detail-field&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edit-input&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edit-description&quot;</span>&gt;</span>Edit<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit-description&quot;</span>&gt;</span>Enter a description<span style="color: #009900;">&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: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flexible-input&quot;</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text-input&quot;</span> <span style="color: #000066;">rows</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;user-desc-text&quot;</span> placeholder<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enter a description&quot;</span>&gt;</span>Enter a description<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</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;">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;submission-buttons group&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;buttons-wrapper&quot;</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">button</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btn btn-special has-tooltip&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit-create&quot;</span>&gt;</span>Digg it <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sprite digg-it-large&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;float-right&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit-cancel&quot;</span>&gt;</span>Cancel<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</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;">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>
<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>
<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>Next it should be simple to cover some of the common CSS queries. There are a few properties and IDs that should be understood well when editing a similar style script. Also we have used a few CSS3 properties new to modern browsers.</p>
<h2>Next Generation CSS</h2>
<p>Our file starts off simple with resetting margins and heading/body styles. There really isn&#8217;t much in the way of fonts, block areas, or other common elements. Since the purpose of our code is tutorial-driven I didn&#8217;t bother to create an extensive list of CSS properties.</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> <span style="color: #ff0000;">'Helvetica Neue'</span><span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.header-wrapper</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;">#1b5790</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.header</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>margin<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>max-<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>min-<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>padding<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.header</span>.size-<span style="color: #993333;">medium</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">min-width</span><span style="color: #00AA00;">:</span><span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>max-<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: #6666ff;">.header</span><span style="color: #6666ff;">.size-simple</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">max-width</span><span style="color: #00AA00;">:</span><span style="color: #933;">680px</span><span style="color: #00AA00;">;</span>min-<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">680px</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;">680px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.header</span> <span style="color: #6666ff;">.digg-logo</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>margin<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.sprite</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'master.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #3333ff;">:-moz-inline-</span>stack<span style="color: #00AA00;">;</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: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span> zoom<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.digg-logo</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">-109px</span><span style="color: #00AA00;">;</span>display<span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>height<span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>text-indent<span style="color: #00AA00;">:</span><span style="color: #933;">-999999px</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;">62px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p>Notice how there is a small class called &#8220;sprite&#8221;. This uses a master.png file which holds all icons and graphics for Digg&#8217;s layout. This is a spriting technique used to save bandwidth and server calls for background graphics.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/white-macbook-iphone-table.jpg" alt="White MacBook with iPhone 3GS" width="510" /></div>
<p>Further down the page we have some newer blocks related to CSS3 queries. Many of the form&#8217;s input fields and buttons include effects generated in-browser through CSS. As one example all input text fields have -webkit-box-shadow set with an inset fall.</p>
<p>This produces a 3-D effect unlike many seen before. The new web standards generate beautiful tonality and with these CSS properties we can design amazing interfaces.</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: #6666ff;">.text-input</span><span style="color: #00AA00;">,</span><span style="color: #6666ff;">.text-input-flat</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>border<span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#80a1c1</span><span style="color: #00AA00;">;</span>color<span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#80a1c1</span><span style="color: #00AA00;">;</span>font-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.16666666667em</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #933;">7px</span> <span style="color: #933;">9px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.text-input</span><span style="color: #3333ff;">:focus</span><span style="color: #00AA00;">,</span><span style="color: #6666ff;">.text-input-flat</span><span style="color: #3333ff;">:focus</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.text-input</span><span style="color: #00AA00;">&#123;</span>box-shadow<span style="color: #00AA00;">:</span><span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#d0d0d0</span><span style="color: #00AA00;">;</span>-moz-box-shadow<span style="color: #00AA00;">:</span><span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#d0d0d0</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;">950px</span><span style="color: #00AA00;">;</span>-webkit-box-shadow<span style="color: #00AA00;">:</span><span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#d0d0d0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
button<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>overflow<span style="color: #00AA00;">:</span><span style="color: #993333;">visible</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
button<span style="color: #00AA00;">:</span><span style="color: #3333ff;">:-moz-focus-inner</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
label<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.block-label</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#373529</span><span style="color: #00AA00;">;</span>display<span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>font-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.16666666667em</span><span style="color: #00AA00;">;</span>font-weight<span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.block-label</span> <span style="color: #6666ff;">.faded</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.inline-label</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span>font-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.16666666667em</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p>A bit lower we have a block of code catered to a few classes. <strong>submission-detail-field</strong> and <strong>now-editing</strong> contain some interesting properties that should be examined a bit further. Initially all content inside a now-editing class has no display. This is changed using jQuery to manipulate how we should our forms.</p>
<p>Submission forms are set by default to look like labels. Once you click to edit them we change the parent division class to now-editing and remove the <code>display:none;</code> clause. From here we can alternate between the two states with ease.</p>
<div class="tutorialimage"><img class="alignNone size-full" src="http://designshack.net/wp-content/uploads/digg-onscreen-footage.jpg" alt="Digg.com Screenshot from a Mac OS X" width="510" /></div>
<p>These CSS styles can work with almost anything. You will notice a few bugs in the system right away. As a short example any buttons or links inside the div won&#8217;t show a mouse pointer on hover. Instead you&#8217;ll get the text bar used to highlight blocks of text &#8211; this can be changed through CSS&#8217; cursor property.</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: #6666ff;">.submission-detail-field</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;">#fff</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">40px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>position<span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>-moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>-webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.submission-detail-field</span> <span style="color: #6666ff;">.flexible-input</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.submission-detail-field</span><span style="color: #6666ff;">.now-editing</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>border-radius<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>-moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>-webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.now-editing</span> p<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.now-editing</span> <span style="color: #6666ff;">.edit-input</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.now-editing</span> <span style="color: #6666ff;">.flexible-input</span><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: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#submit-title</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#356190</span><span style="color: #00AA00;">;</span>font-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.33333333333em</span><span style="color: #00AA00;">;</span>font-weight<span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#submit-description</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#80a1c1</span><span style="color: #00AA00;">;</span>font-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.16666666667em</span><span style="color: #00AA00;">;</span>line-<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.33333333333em</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.edit-input</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#578cca</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>position<span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>cursor<span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>right<span style="color: #00AA00;">:</span><span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>top<span style="color: #00AA00;">:</span><span style="color: #933;">6px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.edit-input</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<h2>Building our Script</h2>
<p>The JavaScript required is fairly straightforward to work with. Luckily jQuery helps by shaving off many lines of code required to target and manipulate DOM objects.</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: #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></pre></div></div>

</div>
<p>We start with our standard ready event checking for our document to finish loading. This is a more precise way of targeting script development since all we really need is a fully loaded Document Object Model to get moving. Many smaller assets throughout the page will continue loading, but instead of waiting our script is executable instantly.</p>
<p>Inside our ready function parameters we pass a new <code>function()</code> designed to handle event listeners. These will check for a certain event to occur and when it does it&#8217;ll execute code set inside of a new function.</p>
<p>This will make more sense with an example, so let&#8217;s start with the first input field.</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: #009900;">&#40;</span><span style="color: #3366CC;">'.edit-input'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> dic <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">parentNode</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> curid <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>dic <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;submission-detail-field&quot;</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: #660066;">parentNode</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'submission-detail-field'</span><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: #660066;">parentNode</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'now-editing'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>curid <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;edit-title&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#user-title-text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>curid <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;edit-description&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#user-desc-text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p>The first line is checking our document for any element(s) with the class &#8220;edit-input&#8221; and binding an event handler to it (or them). The event we&#8217;re looking for is a click event which means whenever the user clicks this element we call another function. In our HTML code <em>.edit-input</em> is a class applied to our edit links.</p>
<p>Once the function begins we are pulling the class name from our containing parent element. We are also grabbing the current ID of our edit link since we can determine if we&#8217;re editing the story title or description. Further down we have code to swap the two classes making our text field editable.</p>
<p>Afterwards there are a few lines of code needed to auto focus the text field and save any results. We could have used an Ajax call to save the data into a database with each click, however the details to do so range beyond this tutorial&#8217;s scope. We would also need support from a backend language such as PHP or Ruby.</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: #009900;">&#40;</span><span style="color: #3366CC;">'#user-title-text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'blur'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> txt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#submit-title'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>txt<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: #660066;">parentNode</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;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'submission-detail-field'</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>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#user-desc-text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'blur'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> txt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#submit-description'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>txt<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: #660066;">parentNode</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;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'submission-detail-field'</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></div></div>

</div>
<p>There is a similar bind event tied to our two form field divisions This will check for the text area containing our story description and works in a similar manner as above. Note that you are able to chain multiple event listeners in this manner to create dynamic form scripts in minutes.</p>
<h2>Conclusion</h2>
<p>This tutorial has given a strong overview of newer CSS3 techniques and classic jQuery functionality. Our final product looks very similar to the Digg submit form without pulling images from a URL which requires Ajax techniques.</p>
<p>All CSS styles and designs have been created in a very similar manner to Digg v4. Better yet, many of the code blocks have been made simple to copy and manipulate into your own page.</p>
<p>As stated previously I have updated both the live demo code and offered a .zip file for download. You can <a href="http://designshack.net/tutorialexamples/DiggJake/index.html">check out my Digg demo code</a> here on DesignShack and also <a href="http://designshack.net/tutorialexamples/DiggJake/digg-v4-input-form.zip">download the archive</a> for your own works. If you have any questions/comments feel free to offer your ideas in the discussion area below.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/javascript/developing-a-digg-style-input-form-with-css3-and-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Return of the Loading Bar: Are CSS3 and HTML5 the New Flash?</title>
		<link>http://designshack.net/articles/css/return-of-the-loading-bar-are-css3-and-html5-the-new-flash/</link>
		<comments>http://designshack.net/articles/css/return-of-the-loading-bar-are-css3-and-html5-the-new-flash/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 21:27:01 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=23212</guid>
		<description><![CDATA[Today we&#8217;re going to discuss a little bit about how and why Flash came to be regarded in a negative light and how we can avoid running down the same path with the modern technologies replacing it. Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay [...]]]></description>
			<content:encoded><![CDATA[<p>Today we&#8217;re going to discuss a little bit about how and why Flash came to be regarded in a negative light and how we can avoid running down the same path with the modern technologies replacing it.</p>
<p><span id="more-23212"></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>Why We Hate Flash</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/newflash-3.jpg" alt="screenshot" width="510"/></div>
<p>Like it or not, the web has turned on Flash. The former Internet poster boy has become a red-headed step child, bringing out feelings of outright hate in many users. This march was largely led by Steve Jobs and Apple&#8217;s refusal to allow Flash on iOS, but every day web users have long had a beef with the technology.</p>
<p>For several reasons, Flash was amazing. It allowed web developers to bring websites to a level of dynamism that was previously impossible. Instead of a land of boring static pages the Internet became a place where truly immersive and downright futuristic experiences were possible. </p>
<p>This all came at a price though. With the rise of Flash the web also became a remarkably buggy and sluggish place. Flash websites of course require the Flash plugin, and if you don&#8217;t have the latest version, you&#8217;d better go get it or this thing isn&#8217;t going to work.</p>
<p>Then came the loading bars. Page load times on pure Flash sites increase exponentially and suddenly &#8220;Loading: 10%… Loading: 11%…&#8221; spinners became part of our daily lives.</p>
<p>Finally, there&#8217;s the problem of stability. Steve Jobs famously stated that most of the time, when Macs crash, Flash is to blame. This is a bit of hyperbole but the core of the statement does hint at some truth. We&#8217;ve all experienced Flash-related freezing and worse. So much so that many people download plugins that block all Flash activity unless it is manually approved.  </p>
<h3>Hollywood Wisdom</h3>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/newflash-2.jpg" alt="screenshot" width="510"/></div>
<p>In the film Jurassic Park, chaos specialist Ian Malcom remarks upon finding an island of living dinosaurs, &#8220;your scientists were so preoccupied with whether or not they could, they didn&#8217;t stop to think if they should.&#8221;</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;Your scientists were so preoccupied with whether or not they could, they didn&#8217;t stop to think if they should.&#8221; -Ian Malcom
</div>
<p></ br></p>
<p>This quote is very appropriate for Flash&#8217;s rise to fame. Developers were so excited about what they could do, they forgot to ask what they <em>should</em> do. Will Flash improve the overall experience or worsen it? What am I gaining by using Flash and what am I sacrificing? Will the majority of my users be satisfied with the decisions that I&#8217;ve made? How large is the pool of users who will miss out and what options will I have for them?</p>
<h2>Repeating History</h2>
<p>Fast-forward to now. CSS3 and HTML5 have arrived to save the day. Flash is on the ropes and takes a fresh beating every day as we see stunning new examples of astounding sites built only with CSS, HTML and JavaScript.</p>
<p>HTML and CSS are built into modern web browsers and are the very backbone of the Worldwide Web as we know it today, so being able to use these technologies to build dynamic pages is a web designer&#8217;s dream come true. </p>
<p>However, as more and more developers pick up these technologies and begin stretching them to the limits, Jurassic Park Syndrome begins to set it. We all become so preoccupied with what is possible that it&#8217;s easy to lose sight of what is permissible.</p>
<p>More and more as I browse the web I&#8217;m starting to see signs that a Flash-like future is approaching. Page load times are increasing to the point that &#8220;loading&#8221; messages are making a comeback, web pages are becoming quite browser-dependent, long animations are causing browser freezes; sound familiar?</p>
<div class="tutorialimage"><a href="http://www.ultranoir.com/en/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/newflash-1.jpg" alt="screenshot" width="510"/></a></div>
<p>Don&#8217;t get me wrong, I&#8217;m the first to stand up and say that HTML5 and CSS3 are not only the future of the web but the source of the best current technologies. However, I think some conversations about caution are appropriate if we are to avoid a Flash-like scenario. </p>
<p>Yes, our new toys are awesome, but let&#8217;s slow down for a minute and ask ourselves a few important questions before implementation.</p>
<h2>Important Questions</h2>
<p>The following is a rough and incomplete list of questions that you should ask yourself before implementing certain next-gen technologies on your site.</p>
<h3>Is The Purpose Experimental/Educational?</h3>
<p>For those of you ready to point a finger at me and my weekly offering of CSS3 techniques, I get a free pass (isn&#8217;t that convenient?). It&#8217;s my job to discuss not only the current state of the web but upcoming trends and technologies. As a result, this blog and other should absolutely be exploring and teaching new techniques as they arise.</p>
<p>As an individual, you also have every right to experiment. There&#8217;s no harm in setting up a web playground or personal website with experimental features. The problem arises when you&#8217;ve been hired to create a site under the assumption that maximum user compatibility is a primary goal. Most companies won&#8217;t be crazy about hiring you to create a site that&#8217;s only impressive to other web designers and slightly annoying to everyone else.</p>
<h3>What Is Gained? What Is Lost?</h3>
<p>Just as I recommended with the implementation of Flash, with any new or experimental technology you should always carefully weigh your pros and cons.</p>
<p>Is the benefit mostly an aesthetic boost? Is it worth a slight hit in usability?  How about a large one? From the average non-designer user&#8217;s perspective, will this choice add to or take away from the experience?</p>
<p>For instance, let&#8217;s say you&#8217;re building a fancy animated drop down menu using pure CSS3 instead of JavaScript, are you doing this because it&#8217;s more impressive or because you know that you can genuinely make it more functional for more users than if you had gone the JS route? </p>
<p>It all comes back to Ian Malcom&#8217;s dilemma. If it turns out that you <em>can</em> pull off a bunch of modern web wizardry on a site, always ask yourself if you <em>should</em>.</p>
<p>Sometimes the advances will actually help streamline your site and make it even more usable, other times you&#8217;ll find yourself with bloated code and a slow page while waving your banner of progress. Just be honest with yourself and decide where to draw the line.</p>
<h3>Will Any Users Miss Out?</h3>
<p>Let&#8217;s say you want to implement some Webkit Keyframe Animations (one of my favorite CSS3 goodies) on a client site, do you first take a look at your analytics to see how many non-Webkit users you&#8217;ll be leaving out?</p>
<p>Browser compatibility was a major problem before HTML5 and CSS3 and is only worse now. The same logic that we&#8217;ve always used still applies though. Just be sure to design with every major browser in mind. As far as I&#8217;m concerned, you shouldn&#8217;t feel bad about implementing browser-specific tricks and effects, just make sure that other users still have a solid experience.</p>
<p>Obviously, we&#8217;re talking about progressive enhancement. Start with a baseline of functionality and aesthetics that work across all major browsers, <em>then</em> add in special extras for those forward-thinking individuals using a truly modern browser. </p>
<h2>Conclusion</h2>
<p>To sum up, I absolutely love HTML5 and CSS3. I spend loads of time experimenting and stretching the bounds of what I previously thought was possible. However, when working on <em>real</em> projects, I&#8217;m always cautious about going overboard and creating a site that not only looks like it was built with Flash, but acts like it!</p>
<p>Leave a comment below and let us know how you approach the use of new technologies on client sites. Are you fully embracing HTML5 and CSS3 or just selectively appealing them where genuine improvements can be made?</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/return-of-the-loading-bar-are-css3-and-html5-the-new-flash/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>CSS Attribute Selectors: How and Why You Should Be Using Them</title>
		<link>http://designshack.net/articles/css/css-attribute-selectors-how-and-why-you-should-be-using-them/</link>
		<comments>http://designshack.net/articles/css/css-attribute-selectors-how-and-why-you-should-be-using-them/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 22:52:02 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[attribute selectors]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=22510</guid>
		<description><![CDATA[Today we&#8217;re going to learn about Attribute Selectors. What are they? How do I use them? What are the new CSS3 Attribute selectors? We&#8217;ll answer these questions and more. Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay up on recent content. HTML Attributes Before I [...]]]></description>
			<content:encoded><![CDATA[<p>Today we&#8217;re going to learn about Attribute Selectors. What are they? How do I use them? What are the new CSS3 Attribute selectors? We&#8217;ll answer these questions and more. </p>
<p><span id="more-22510"></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>HTML Attributes</h2>
<p>Before I introduce you to the concept of CSS attribute selectors, you should know what an HTML attribute is. The good news is, you&#8217;re already familiar with several of them: <em>class</em>, <em>id</em>, <em>style</em>, and <em>href</em> for example. There are a ton more though, check out <a href="http://www.w3.org/TR/html4/index/attributes.html">W3.org</a> for a complete list.</p>
<p>CSS makes styling some attributes easy. For instance, if we want to style an <em>id</em> or <em>class</em>, we just use the following.</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;">#someid</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.someclass</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This is all well and good, but what if we want to style some other attributes? This is where attribute selectors come into play. </p>
<h2>Attribute Selectors</h2>
<p>As we just learned, attribute selectors are exactly what they sound like, a way to select and target specific attributes using CSS. This is actually really easy to do and just involves a set of brackets containing the HTML that you used. Let&#8217;s see how this works by looking first at some basic HTML.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;ul<span style="color: #00AA00;">&gt;</span>
    &lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;http://designshack.net/&quot;</span><span style="color: #00AA00;">&gt;</span>Design Shack&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span>
    &lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;http://www.smashingmagazine.com/&quot;</span><span style="color: #00AA00;">&gt;</span>Smashing Magazine&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span>
    &lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;http://sixrevisions.com/&quot;</span><span style="color: #00AA00;">&gt;</span>Six Revisions&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span>
&lt;/ul<span style="color: #00AA00;">&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>Let&#8217;s say I wanted to target and style only the Design Shack link. I could use pseudo selectors, but this assumes the list stays in that order and browser support isn&#8217;t the best. Instead, what we can do is use an attribute selector to target the specific &#8220;href&#8221; that we&#8217;re interested in.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'http://designshack.net/'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/attributeselectors-1.jpg" alt="screenshot" width="510"/></div>
<h3>Repeating Attributes</h3>
<p>Another example that&#8217;s used a lot is a list of contacts, one or more of which should be styled a certain way. Using attributes, we can differentiate between friends and contacts.</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>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;friend&quot;</span>&gt;</span>Larry<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact&quot;</span>&gt;</span>Curly<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact&quot;</span>&gt;</span>Moe<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact&quot;</span>&gt;</span>Curly Joe<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;friend&quot;</span>&gt;</span>Shemp<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;">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>We can then go in and style each of these <em>rel</em> attributes differently using the same syntax as above. Much like with a class, multiple items can meet the criteria in one declaration.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li a<span style="color: #00AA00;">&#91;</span>rel<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'friend'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li a<span style="color: #00AA00;">&#91;</span>rel<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'contact'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">200</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Using this code we can achieve the results below. Notice that even if we start adding in new contacts to the top of the list, these selectors will still work where <em>:nth-child</em> wouldn&#8217;t. Pretty cool right? Further, just about every current browser supports these, including IE back to version 7!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/attributeselectors-2.jpg" alt="screenshot" width="510"/></div>
<p>It&#8217;s also important to note that you don&#8217;t have to be so specific. The following will style <strong>any</strong> element with a <em>rel</em> attribute applied.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li a<span style="color: #00AA00;">&#91;</span>rel<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Handling Multiples Values</h3>
<p>The tricky part about using Attribute selectors is that they get a little funny when there is multiple attributes. Consider the following tweak to our previous list.</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>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;friend nofollow&quot;</span>&gt;</span>Larry<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact&quot;</span>&gt;</span>Curly<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contact&quot;</span>&gt;</span>Moe<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;">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>You would think that styling the first list item would be the same process considering it still has &#8220;friend&#8221; in it, but that&#8217;s not the case. Simply using <em>=&#8217;friend&#8217;</em> won&#8217;t successfully target this anymore. Instead, we have to use the following, which looks for &#8220;friend&#8221; as one of the <em>rel</em> values.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li a<span style="color: #00AA00;">&#91;</span>rel~<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'friend'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This will result in the &#8220;Larry&#8221; list item being bolded where as the previous <em>a[rel='friend']</em> syntax would&#8217;ve missed it. </p>
<h2>CSS3 Attribute Selectors</h2>
<p>CSS3 has given us so many cool new toys and tools to play with. It&#8217;s no surprise then that there are also some new Attribute Selectors that help us bring even more specificity into our targeting. Let&#8217;s start with my favorite. </p>
<h3>Styling Similarly Named Attributes</h3>
<p>This is where things get awesome. Let&#8217;s say you had the following HTML and that you wanted to target only the <em>upperSection</em> and <em>lowerSection</em>, how would you do it?</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;upperSection&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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>
&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;somethingElse&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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>
&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;lowerSection&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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>
&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;footer&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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></pre></div></div>

</div>
<p></ br></p>
<p>One easy answer is the new &#8220;Arbitrary Substring Attribute Value Selector&#8221;, or &#8220;the really cool little asterisk thing.&#8221; Since the two divs that we want to target both contain &#8220;Section&#8221; in their names, we can easily target them. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #00AA00;">&#91;</span>id<span style="color: #00AA00;">*=</span><span style="color: #ff0000;">'Section'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>I was blown away by this. Here we&#8217;re using CSS to actually dig through our ID names to find specific values within a larger name and target those elements. This opens up a lot of possibilities and makes complex targeting with little markup a much easier task. </p>
<h3>Beginning and Ending</h3>
<p>While the Arbitrary Substring Attribute Value Selector will target a given string anywhere, the Beginning and Ending versions allow rarer cases to be handled where you only want the first or last item to be considered. </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>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stooge one&quot;</span>&gt;</span>Larry<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;the second stooge&quot;</span>&gt;</span>Curly<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stooge three&quot;</span>&gt;</span>Moe<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;impostor&quot;</span>&gt;</span>Curly-Joe<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;">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>Let&#8217;s say we want to target all the stooges, making Larry and Moe red and Curly yellow. To do this, we can insert use <em>[title^='stooge']</em> to grab all those with &#8220;stooge&#8221; as the first word and <em>[title$='stooge']</em> to grab all those with &#8220;stooge&#8221; as the last word.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li a<span style="color: #00AA00;">&#91;</span>title<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">'stooge'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*Beginning*/</span>
li a<span style="color: #00AA00;">&#91;</span>title$<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'stooge'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">yellow</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*Ending*/</span></pre></div></div>

</div>
<p></ br></p>
<h3>Chaining Attribute Selectors</h3>
<p>Let&#8217;s say you want to get super specific and add on multiple criteria. That&#8217;s as simple as chaining together multiple attribute selectors. Let&#8217;s see how this works with the HTML below.</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>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stooge one&quot;</span>&gt;</span>Larry<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;the second stooge&quot;</span>&gt;</span>Curly<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stooge three&quot;</span>&gt;</span>Moe<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;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;the impostor&quot;</span>&gt;</span>Curly-Joe<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;">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>Now, let&#8217;s target any link with &#8220;stooge&#8221; in the title, but only those beginning with &#8220;the&#8221;. Notice that we don&#8217;t want to casually target &#8220;the&#8221; because this also appears in the last item. Here&#8217;s the syntax for achieving this:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li a<span style="color: #00AA00;">&#91;</span>title<span style="color: #00AA00;">*=</span><span style="color: #ff0000;">'stooge'</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#91;</span>title<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">'the'</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Simple right? All we did was take the two rules that we needed and put them on the same line. It&#8217;s important to note that this isn&#8217;t an either/or scenario but a both/and. Only those items that meet both criteria will be changed. </p>
<h2>Further Reading</h2>
<p>If you&#8217;re enough of a nerd that you&#8217;re just loving attribute selectors, there are two more sources that I highly recommend that you check out. </p>
<h3><a href="http://css-tricks.com/5591-attribute-selectors/">CSS Tricks</a></h3>
<p>First, Chris Coyier has a very thorough introduction over at <a href="http://css-tricks.com/5591-attribute-selectors/">CSS Tricks</a> covering much of the same content that we covered here. Chris is a CSS super genius though and likely explains them much better than me!</p>
<h3><a href="http://designshack.net/articles/reviews/review-the-book-of-css3-a-css-book-even-experts-should-read/">The Book of CSS3</a></h3>
<p>Next, check out Peter Gasston&#8217;s <a href="http://designshack.net/articles/reviews/review-the-book-of-css3-a-css-book-even-experts-should-read/">The Book of CSS3</a>, which has been my main reference for all things CSS3 lately. I simply can&#8217;t get enough of this book and have given it quite the permanent position on my desk! Gasston adds to this conversation with a discussion of General and Adjacent Sibling Combinators, which are another interesting way to target certain elements. Take the following HTML as an 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;combinators&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Not this one.<span style="color: #009900;">&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: #000000; font-weight: bold;">h1</span>&gt;</span>Gibberish<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Pick me!<span style="color: #009900;">&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: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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></pre></div></div>

</div>
<p></ br></p>
<p>Now, let&#8217;s say we wanted to target only the &#8220;Pick me!&#8221; paragraph. The Adjacent Sibling Combinator let&#8217;s us do just that. The following code targets any <em>p</em> tags immediately preceded by an <em>h1</em> tag. There is only one of these in the example above (the first paragraph after the header).</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">+</span> p <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> orange<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Similarly, the General Sibling Combinator will allow us to target <strong>all</strong> of the <em>p</em> tags that come after the header. So that first paragraph won&#8217;t change color, but all of the others will.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">h1 ~ p <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> orange<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This is just a taste, for more information on these, check out The Book of CSS3. </p>
<h2>Browser Support</h2>
<p>As I mentioned briefly above, as far as I can tell, you&#8217;re pretty covered on most of these techniques back to IE7 with all <strong>major</strong> current browsers rocking perfect support. However, it&#8217;s not exactly a full score across the board with some of the lesser-known browsers being a little spotty. You can find a nice little table of browsers and their support for all of this stuff and more at <a href="http://dev.l-c-n.com/CSS3-selectors/browser-support.php">dev.l-c-n.com</a>. </p>
<h2>Conclusion</h2>
<p>To be honest, I very recently knew little to nothing about CSS attribute selectors. After a little bit of research though I was stunned by how cool they are and baffled as to why they seem to be so rare (browser support is better than for a lot of the stuff we mess with). With just a little bit of code, you can achieve remarkably specific targeting with little to no additional markup required.</p>
<p>Leave a comment and let me know what you think of attribute selectors and whether or not you ever use them!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/css-attribute-selectors-how-and-why-you-should-be-using-them/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Build a Web Page With CSS3 Flexbox</title>
		<link>http://designshack.net/articles/css/build-a-web-page-with-css3-flexbox/</link>
		<comments>http://designshack.net/articles/css/build-a-web-page-with-css3-flexbox/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 18:01:49 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[flexbox]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=22132</guid>
		<description><![CDATA[Yesterday we discussed the future of CSS layout and a few of the new modules that CSS3 brings to the table in this arena. One of these that we briefly touched on was CSS3 Flexbox. Today we&#8217;re going to dig deeper into this model and build a full-on web page with it. It will by [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we discussed the <a href="http://designshack.net/articles/css/farewell-floats-the-future-of-css-layout/">future of CSS layout</a> and a few of the new modules that CSS3 brings to the table in this arena. One of these that we briefly touched on was CSS3 Flexbox.</p>
<p>Today we&#8217;re going to dig deeper into this model and build a full-on web page with it. It will by no means be ready to implement on your projects but it will give you further insight into one possible way that we will be coding websites in years to come. Plus, this stuff is just flat out fun to play with!</p>
<p><span id="more-22132"></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>Highly Experimental: Webkit Only</h2>
<p>My goal for this post was to have a working page up and running on several browsers, that didn&#8217;t happen. At this point the implementation is buggy and inconsistent across browsers, even after installing <a href="http://flexiejs.com/">Flexie.js</a>, I was still getting vastly different results between Firefox and Safari (I think it has to do with mixing typical margin-centered containers and Flexbox).</p>
<p>For this reason, today&#8217;s project will primarily be targeted at <strong>Safari and Chrome</strong> because frankly, it&#8217;s still a mess in other browsers! I definitely encourage you to follow along and then play with the finished product to see if you can get it up and running in a cross-browser implementation. If you have suggestions, I&#8217;d love to hear them in the comments!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-6.jpg" alt="screenshot" width="510"/></div>
<h2>Step 1: Reusable Classes</h2>
<p>Since I briefly explained the basic concept of Flexbox in <a href="http://designshack.net/articles/css/farewell-floats-the-future-of-css-layout/">yesterday&#8217;s post</a>, I&#8217;ll be focusing on implementation here. But don&#8217;t worry, you should get the gist as we go along.</p>
<p>The first thing we want to do is create some basic classes that will help define our layout. These attributes can be applied to an ID on an as-needed basis, but I find it helpful to and tidy to do it this way. </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: #6666ff;">.hasflex</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -webkit-box<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-box<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.box0</span> <span style="color: #00AA00;">&#123;</span>
    -webkit-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    -moz-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.box1</span> <span style="color: #00AA00;">&#123;</span>
    -webkit-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
    -moz-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
    box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.box2</span> <span style="color: #00AA00;">&#123;</span>
    -webkit-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
    -moz-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
    box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.box3</span> <span style="color: #00AA00;">&#123;</span>
    -webkit-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span>
    -moz-box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span>
    box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.last</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Let&#8217;s discuss how these classes work. The first class, <em>hasflex</em>, will be applied to a parent container whose children we want to lay out using this new Flexbox system. One thing you&#8217;ll notice is that this entire design will be completely without floats so that gives you some good indications as to where we will be implementing Flexbox in our code.</p>
<p>Next, we set up a few more classes to apply various <em>box-flex</em> values. Flexbox will conveniently distribute our child elements across the container and these will define the proportions. I <em>believe</em> that the default value is &#8220;0&#8243; but the results seemed a little buggy with this assumption so I found it helpful to always just apply a value manually. </p>
<h2>Step 2: Initial HTML &#038; CSS</h2>
<p>To start off your HTML document, create a container and a header. At this point, these are basic elements that we will build just like always without the aid of Flexbox.</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;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Design Shack Flexbox Demo<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</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;">div</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>Once you&#8217;ve got that in place, throw in the basic styles below. Basically I set up a dark body with a light 1,000px wide container that will hold all of our content. Toss in some margins to center and some basic text styles and we&#8217;re ready to move on to the fun stuff. </p>
<p><strong>Note:</strong> The headline font I&#8217;ll be using is <a href="http://www.google.com/webfonts/family?family=Oswald&#038;subset=latin#code">Oswald, from Google Fonts</a>.</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: #808080; font-style: italic;">/*Basic Reset*/</span>
&nbsp;
<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;
<span style="color: #808080; font-style: italic;">/*Body/Container*/</span>
&nbsp;
body <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> arial<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;">15px</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;">23px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#111</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
&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: #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: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1150px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Header*/</span>
&nbsp;
<span style="color: #cc00cc;">#header</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: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">900px</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;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Oswald'</span><span style="color: #00AA00;">,</span> arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h2>Step 3: Navigation</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-1.jpg" alt="screenshot" width="510"/></div>
<p>Now, for the navigation area, you typically create a list of links and then float them to the left. With Flexbox, the process is a little different. Here we simply apply the <em>hasflex</em> class that we created earlier and then use <em>box0</em> for each of the list items. Applying <em>box0</em> to all three has the effect of floating the links to the left but won&#8217;t distribute them all the way across the width of the container.</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;nav&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hasflex&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box0&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box0&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>About<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box0&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Contact<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&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>
<p>After this, we simply apply the same types of styles we would on any other web page. The main goal here is to space the links out a little with some margins and to make sure our links are styled properly.</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: #808080; font-style: italic;">/*Navigation*/</span>
&nbsp;
<span style="color: #cc00cc;">#nav</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;">900px</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/*background: #eee;*/</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;">#nav</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#nav</span> ul li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#nav</span> a <span style="color: #00AA00;">&#123;</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: #cc00cc;">#111</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#nav</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h2>Step 4: The Image</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-2.jpg" alt="screenshot" width="510"/></div>
<p>Every good web page needs an image. To further illustrate how you selectively apply Flexbox only to those elements that need it, we&#8217;ll throw in a large header image using the same exact code as you typically would.</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;bigimage&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://lorempixum.com/900/300/food/1&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></pre></div></div>

</div>
<p></ br></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: #808080; font-style: italic;">/*Image*/</span>
&nbsp;
<span style="color: #cc00cc;">#bigimage</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">900px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h2>Step 5: Three Columns: Horizontal</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-3.jpg" alt="screenshot" width="510"/></div>
<p>This is where Flexbox really shines. Normally, creating a three column layout like the one shown above would involve a good amount of mathematical planning. We would need to not only split the parent container in three but also figure out the proper proportions so that the middle column is wider than the other two.</p>
<p>However, with Flexbox, all we have to do is apply our <em>flexbox</em> class in conjunction with the numbered box classes. Here I set the middle div to <em>box2</em> and the others to <em>box3</em>. As you can see in the image above, the effect of this is an automatic distribution of the columns with the second being wider than the first.</p>
<p>Interestingly enough, everything I read led me to believe that the <em>box2</em> class would be the narrowest in this instance, but that simply wasn&#8217;t the case in my live tests! This setup brings about a narrow first and last paragraph and a wide second paragraph.</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;columns&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hasflex&quot;</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;box3&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>One<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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>
&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;box2&quot;</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Long Two<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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>
&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;box3&quot;</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Three<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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;">div</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>Combine this with some basic CSS and you&#8217;ve got a quick and easy three column layout! Since Flexbox automatically takes care of the distribution relative to the parent width, any changes we make to the parent will automatically be reflected in the children. </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: #808080; font-style: italic;">/*Text Columns: 3 Wide*/</span>
&nbsp;
<span style="color: #cc00cc;">#columns</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;">900px</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/*background: gray;*/</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#columns</span> p <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: #933;">15px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#columns</span> h2 <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: #933;">30px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">0px</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;">35px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Oswald'</span><span style="color: #00AA00;">,</span> arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>One fascinating thing about Flexbox is that we could actually reorder the columns that we setup using pure CSS. Assigning <em>-webkit-box-ordinal-group: (a number);</em> to each element gives you control over the order of their appearance.</p>
<h2>Step 6: Vertical Stack</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-4.jpg" alt="screenshot" width="510"/></div>
<p>It&#8217;s important to learn that you don&#8217;t have to use vertical columns when working with Flexbox. We can use the same technique as above to stack a few paragraphs on top of each other. If you really get into Flexbox, this technique can be used to mix vertical and horizontally stacked elements, but we&#8217;ll keep it basic here just to see how it works.</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;rows&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hasflex&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Long Two<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box1&quot;</span>&gt;</span>Lorem ipsum dolor sit amet... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span> 
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box1&quot;</span>&gt;</span>Lorem ipsum dolor sit amet... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span> 
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box1&quot;</span>&gt;</span>Lorem ipsum dolor sit amet... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span> 
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>The primary difference here is that we&#8217;ve set <em>box-orient</em> to vertical, which gives us the vertical stack shown in the image above instead of the columns that we created in the previous step.</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: #808080; font-style: italic;">/*Text Rows*/</span>
&nbsp;
<span style="color: #cc00cc;">#rows</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;">900px</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/*background: gray;*/</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">30px</span> <span style="color: #993333;">auto</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
    -webkit-box-orient<span style="color: #00AA00;">:</span> vertical<span style="color: #00AA00;">;</span>
    -moz-box-orient<span style="color: #00AA00;">:</span> vertical<span style="color: #00AA00;">;</span>
    box-orient<span style="color: #00AA00;">:</span> vertical<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#rows</span> p <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: #933;">0px</span> <span style="color: #933;">15px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#rows</span> h2 <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">35px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Oswald'</span><span style="color: #00AA00;">,</span> arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h2>Step 7: Two Columns</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-5.jpg" alt="screenshot" width="510"/></div>
<p>Just to switch things up one last time, let&#8217;s create another section, this time with two columns instead of three. The principle is exactly the same. You don&#8217;t have to rethink the layout because you have two columns this time around, Flexbox takes care of all the heavy lifting once again.</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;twoColums&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hasflex&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;box2&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>One<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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>
&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;box1&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Two<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>Lorem ipsum dolor sit amet...<span style="color: #009900;">&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;">div</span>&gt;</span></pre></div></div>

</div>
<p></ br></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: #808080; font-style: italic;">/*twoColums*/</span>
<span style="color: #cc00cc;">#twoColums</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;">900px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#twoColums</span> p <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: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#twoColums</span> h2 <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">35px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Oswald'</span><span style="color: #00AA00;">,</span> arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h2>Finished Product</h2>
<p>Check out a <a href="http://designshack.net/tutorialexamples/FlexBox/index.html">live demo</a> if you&#8217;re in Safari or Chrome. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/ds-flexbox-6.jpg" alt="screenshot" width="510"/></div>
<h2>Going Further</h2>
<p>I intentionally tried to keep this example as simple as possible. However, you can pretty easily take this layout and make it even more complex. For starters, using percentages for width will give you a nice, truly flexible layout. Also, as I mentioned above, you can perform complex actions such as rearranging columns and mixing vertical and horizontal stacks in the same row. I encourage you to play with the code as much as possible using <a href="http://www.html5rocks.com/en/tutorials/flexbox/quick/">this page</a> as a guide.</p>
<h2>Conclusion</h2>
<p>This basic example is meant to shed further light into how we could be using Flexbox to create both simple and complex layouts sometime in the future. I&#8217;m fairly new to the module so this is <em>far</em> from perfect, as evidenced by the fact that it isn&#8217;t cross-browser compatible yet!</p>
<p>Despite its downfalls, you should have a strong grasp of how the module works and what can be done with a relatively small amount of code when leveraging Flexbox. Feel free to toss in plenty of suggestions in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/build-a-web-page-with-css3-flexbox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Farewell Floats: The Future of CSS Layout</title>
		<link>http://designshack.net/articles/css/farewell-floats-the-future-of-css-layout/</link>
		<comments>http://designshack.net/articles/css/farewell-floats-the-future-of-css-layout/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 18:55:48 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=22102</guid>
		<description><![CDATA[Floats are one of the most basic tools for structuring a web page using CSS. They&#8217;re both one of the very first things that we learn about and one of the last things that we truly master. Today&#8217;s article looks at some of the reasons that floats are pretty lame and takes a look at [...]]]></description>
			<content:encoded><![CDATA[<p>Floats are one of the most basic tools for structuring a web page using CSS. They&#8217;re both one of the very first things that we learn about and one of the last things that we truly master. </p>
<p>Today&#8217;s article looks at some of the reasons that floats are pretty lame and takes a look at a number of alternative layout systems, some of which are still under development but may one day represent the standard for CSS-based layout.</p>
<p><span id="more-22102"></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 Tale of Tables</h2>
<p>Once upon a time, web designers used HTML tables to accomplish complex page layouts. Though it was a messy, non-semantic process, it attempted to make the best of the available technology to create better designs.</p>
<p>For newbies, when I say &#8220;non-semantic,&#8221; I mean that table-based layout is a bastardization of the table element. It&#8217;s meant to hold actual tables of information within a page, not to serve as the structure for the page itself. </p>
<h2>Floats: The New Tables?</h2>
<p>Today, we scoff at this practice. What a silly way to lay out a website! CSS has come to our rescue and provided us with several tools for creating much more semantic layouts that can easily achieve anything that was created with a table.</p>
<p>Today one of the primary ways that we have replaced our table-dependent ways is the use of floats for layout. By default, sequential HTML elements will appear vertically stacked. Floats serve as a way for us to line elements up horizontally. Float a list of li elements to the left and you&#8217;ve got yourself a nice little horizontal navigation menu. </p>
<p>Though many of us have simply grown accustomed to using them, floats are far from ideal. They&#8217;re awkward, buggy and difficult to learn. If you think back to when you first began CSS-based layout, the thing that had you scratching your head and troubleshooting for hours was probably a float gone wrong. </p>
<h3>The Clearfix Band-Aid</h3>
<p>The bane of float-based layouts (aside from IE6 margin nightmares) is of course the fact that they simply don&#8217;t play well with their container elements. In order to get the parent element to appear as if it contains floated elements, we typically insert a cleared element last in the container using &#8220;clear:both&#8221;. </p>
<p>Is creating an empty container to hack a broken layout a good practice? Probably not. Does it work? You bet. </p>
<h3>A Better Clearfix</h3>
<p>Forward thinkers have decided that this business of adding additional HTML markup is no good. The current favorite way to clear a float is to instead insert the new element using the CSS &#8220;:after&#8221; pseudo class. </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: #6666ff;">.clearfix</span><span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Once again, this is acceptable because of how accustomed we are to messing with floats to bend them to our will. However, try taking a step back and really looking at what&#8217;s going on here. This is a mess! We&#8217;re using CSS to insert an invisible element into the HTML so that our layout problems magically disappear as we shiver at the thought of using table-based layouts because they aren&#8217;t semantic.</p>
<p>I&#8217;m not defending table-based layout, it&#8217;s dead and needs to stay that way, but I can&#8217;t help but wonder if future web designers will laugh at our use of floats the way that we now laugh at the thought of a web page built on a table. </p>
<h2>The Future</h2>
<p>You have to admit, if you really think about it, floats are a pretty screwed up and complicated way to handle page layout. I don&#8217;t see floats going completely away any time soon, they&#8217;ll likely still be useful even if we all do accept a new layout process.</p>
<p>However, there are several interesting layout tools on the horizon that could very well replace floats as a primary way that to structure web pages. Let&#8217;s take a look at some of these ideas and constructs and see if we can get a glimpse into what the future of CSS layout will be like. </p>
<h2>Inline-Block</h2>
<p>Before we dive into futuristic experimental layout techniques, it&#8217;s worthwhile to discuss <em>inline-block</em> as an interesting alternative to float-based layouts. Consider the snippet below:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul li <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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*helps with variable length content*/</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This will actually cause our list items to appear inline while retaining their block attributes, which is completely amazing really! We get the best of both worlds.</p>
<h3>Downfalls of Inline-Block</h3>
<p>Andrew Tetlaw from Sitepoint recently <a href="http://www.sitepoint.com/give-floats-the-flick-in-css-layouts/">published a fantastic article</a> that highly praises using <em>inline-block</em> over floats. He correctly points out that this method works effectively on all modern browsers, including IE8 and above, which is about the same as you can expect from the pseudo-class-driven clearfix from above.</p>
<p>Unfortunately, as <a href="http://robertnyman.com/2010/02/24/css-display-inline-block-why-it-rocks-and-why-it-sucks/">Robert Nyman points out</a> in a similar article, this method isn&#8217;t without its problems.</p>
<p>In addition to the IE troubles (he has a clever hack to get support in IE7), Nyman shows using <em>inline-block</em> causes your layout to be somewhat whitespace dependent when it comes to your HTML. The example he uses is the following unordered list:</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;display-inline-block-example&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Item one<span style="color: #009900;">&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;</span>Item two<span style="color: #009900;">&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;</span>Item three<span style="color: #009900;">&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>Believe it or not, the line returns automatically cause a slight margin to be added to the list items! The only way to fix it is to place them on the same line:</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;display-inline-block-example&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Item one<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Item two<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Item three<span style="color: #009900;">&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>Admittedly, it&#8217;s a fairly easy fix, but if you&#8217;re a fan of neatly organized code, this may make you cringe. On the whole, when compared to the trouble that we face using floats, Tetlaw has a point that this may be a better solution that you can actually use now with an acceptable amount of browser support. </p>
<h2>Flexbox</h2>
<p>One of the new ways that CSS3 is changing layout practices is through the Flexible Box Module, or Flexbox for short. Here&#8217;s a quote from the <a href="http://www.w3.org/TR/css3-flexbox/">Flexbox w3 abstract.</a> </p>
<p><em>[Flexbox] provides an additional layout system alongside the ones already in CSS. [CSS21] In this new box model, the children of a box are laid out either horizontally or vertically, and unused space can be assigned to a particular child or distributed among the children by assignment of &#8220;flex&#8221; to the children that should expand. Nesting of these boxes (horizontal inside vertical, or vertical inside horizontal) can be used to build layouts in two dimensions.</em></p>
<p>Flexbox represents a completely new way to layout websites. You may have heard about this recently but the syntax is changing a bit so make sure you keep an eye on the working spec to stay up to date (I believe &#8220;box&#8221; will change to &#8220;flex&#8221; or &#8220;flexbox&#8221; in most cases). The current working CSS syntax for applying flexbox is as follows:</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: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -webkit-box<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-box<span style="color: #00AA00;">;</span></pre></div></div>

</div>
<p></ br></p>
<p>To see how it works, let&#8217;s jump right into an example. Basically, once you apply <em>display: box</em> to the parent element, the children can be automatically redistributed based on simple relative sizing. </p>
<p>Imagine we have three paragraph tags (these will serve as columns) inside a parent container with <em>display: box</em> applied and we want the middle column to be twice the width of the other two. Here&#8217;s what we do: </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">#box2 {
    -webkit-box-flex: 1;
    -moz-box-flex: 1;
    box-flex: 1;
}</pre></div></div>

</div>
<p></ br></p>
<p>With that little bit of code (plus some superfluous visual styling), we can achieve the following result.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-1.jpg" alt="screenshot" width="510"/></div>
<p>Note that the default value is &#8220;0&#8243; for <em>box-flex</em>. Changing the second box to &#8220;2&#8243; triggered the command to fill the width while making the second box wider than the other two. Let&#8217;s consider a few more examples so you can really get a feel for how it works. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-2.jpg" alt="screenshot" width="510"/></div>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-3.jpg" alt="screenshot" width="510"/></div>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-4.jpg" alt="screenshot" width="510"/></div>
<p>As you can see, Flexbox has dramatic implications to the way we structure websites with CSS. Not only does this have the potential to solve the problems associated with floats, it makes multi-column grid-based layouts infinitely easier!</p>
<h3>Dig Deeper</h3>
<p>This article is merely meant as an introduction to new layout methods and is not in any way exhaustive. I&#8217;ve barely scratched the surface of what what Flexbox can do. For instance, you can accomplish the same thing we did above with vertically stacked elements and completely rearrange the boxes using only CSS.</p>
<p>For more on what can be done with Flexbox, I <em>highly</em> recommend that you play with <a href="http://flexiejs.com/playground/">Flexie, The Flexbox Playground</a>. This will give you hands-on experience with the new layout system and allow you to try each setting to get a feel for the result.</p>
<h2>The Template Layout Module</h2>
<p>Another proposed idea for CSS layout is the Template Layout Module. Here&#8217;s a quote from the <a href="http://www.w3.org/TR/2009/WD-css3-layout-20090402/">official spec</a>.</p>
<p><em>&#8220;The properties in this specification work by associating a layout policy with an element. Rather than letting an element lay out its descendants in their normal order as inline text or as blocks of text (the policies available in CSS level 1), the policy defined in this module, called template-based positioning, gives an element an invisible grid for aligning descendant elements.&#8221;</em></p>
<p>The Template Layout Module uses a quirky but straightforward syntax that makes layout a breeze. The first thing you need to do is create a container with some child elements. For each child element, you assign an arbitrary letter (it doesn&#8217;t matter which letter, just make sure they&#8217;re unique).</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;">#div1</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> a<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#div1</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> b<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#div1</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> c<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Next, you apply a display value to the parent element using these letters to define your proportions. For example, to create three equal columns, simply type them all in a row:</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;">display</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;abc&quot;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This will give you the following result:</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-5.jpg" alt="screenshot" width="510"/></div>
<p>If you want to rearrange the boxes, simply rearrange the letters in your CSS. Instead of typing &#8220;abc&#8221;, try typing &#8220;bca&#8221;.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-6.jpg" alt="screenshot" width="510"/></div>
<p>To create a new row, create a new set of quotes. You can repeat letters to set a sense of proportion. For instance, here we set the first row to &#8220;ab&#8221; and the second to &#8220;cc&#8221;, meaning &#8220;c&#8221; will be twice the width of &#8220;a&#8221; or &#8220;b&#8221;. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/futurelayout-7.jpg" alt="screenshot" width="510"/></div>
<p>Each section (a,b,c) is referred to as a &#8220;slot&#8221;. To create an empty slot, simply use a period: &#8220;a.b.c&#8221; will create two empty slots in our row. To target a slot for additional styling, you use the slot pseudo element:</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;">::</span>slot<span style="color: #00AA00;">&#40;</span>c<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Dig Deeper</h3>
<p>As with the previous example, there&#8217;s a lot more that can be done here such as setting heights and widths using precise dimensions or percentages. None of it is ready to use in any browser at the moment but you can install a <a href="http://code.google.com/p/css-template-layout/">jQuery plugin</a> to test it out! Check out the <a href="http://a.deveria.com/csstpl/">plugin&#8217;s demo pages</a> for some awesome coded examples of how to create any layout you want using the Template Layout Module. </p>
<h2>Back to Tables?</h2>
<p>The <a href="http://www.sitepoint.com/give-floats-the-flick-in-css-layouts/">Andrew Tetlaw Sitepoint article</a> that I mentioned before presents one more interesting option for layout. </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: #6666ff;">.nav</span> <span style="color: #00AA00;">&gt;</span> ul <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> table<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.25em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Interestingly enough, setting the &#8220;display&#8221; property to &#8220;table&#8221; allows us to structure our layout as if they were tables. Right away I know this is going to freak a lot of people out. Reverting back to table-based layout!? Are you nuts? The crazy part is though that this is in fact a completely different practice than literally using a table element. Here you&#8217;re simply telling the CSS to position elements <em>similarly</em> to how table cells and rows are positioned.</p>
<p>Personally, I still like the new fancy CSS3 methods that we just covered a lot better and really have a hard time imagining this gaining widespread acceptance, but it&#8217;s worth checking out and discussing nonetheless. If you&#8217;re interested, be sure to check out <a href="http://www.sitepoint.com/give-floats-the-flick-in-css-layouts/">Tetlaw&#8217;s explanation</a>.</p>
<h2>Conclusion</h2>
<p>The point of this article was to get you thinking about how floats may not necessarily be the best way to structure websites. Though they&#8217;re one of the best solutions that we can currently use in live client projects, they represent a fairly sloppy and broken system that is far from ideal.</p>
<p>There are a number of ways that you can address the downfalls of floats. For now, you could check out &#8220;display: inline-block&#8221; as one option or even look into &#8220;display: table&#8221; if you&#8217;re particularly brave.</p>
<p>The wizards that make all this technology work recognize that the system is broken and are hard at work solving the problems with layout modules that may prove extremely useful in the future. Expect to hear a lot more on the Flexbox and Template Layout modules in the future. Who knows, one or both of these could be the standard way that future developers create web layouts!</p>
<p>Leave a comment and let us know your thoughts on all this. Do you think floats represent a flawed layout system? Do any of the proposed layout modules seem like a solid fix for these issues? </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/farewell-floats-the-future-of-css-layout/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>20+ Free CSS3 Code Generators</title>
		<link>http://designshack.net/articles/css/20-free-css3-code-generators/</link>
		<comments>http://designshack.net/articles/css/20-free-css3-code-generators/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 18:41:17 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=10587</guid>
		<description><![CDATA[One of the biggest problems with all the new CSS3 properties is that most of them have multiple browser-specific implementations. This means when you want a simple shadow, you have to remember quite a bit of code to make it compatible across as many browsers as possible. To help you out with this task, a [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-18.jpg" alt="screenshot" width="510"/></div>
<p>One of the biggest problems with all the new CSS3 properties is that most of them have multiple browser-specific implementations. This means when you want a simple shadow, you have to remember quite a bit of code to make it compatible across as many browsers as possible. </p>
<p>To help you out with this task, a bunch of intrepid coders have created free interactive tools that provide simple user interfaces that spit out all the code you need with a fully customizable end result. Below you&#8217;ll find over twenty of these CSS3 generators. </p>
<p><span id="more-10587"></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 href="http://css3generator.com/">CSS3 Generator</a></h2>
<p>Definitely one of the most popular options. All the effects are fully customizable and you can choose from all the popular CSS3 properties.</p>
<div class="tutorialimage"><a href="http://css3generator.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-4.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://css3please.com/">CSS3 Please</a></h2>
<p>Another really popular option, this one allows you to edit the code just like you&#8217;d see it in a code editor. The changes are reflected on a graphic in the upper right.</p>
<div class="tutorialimage"><a href="http://css3please.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-5.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://www.impressivewebs.com/css3-click-chart/">CSS3 Click Chart by Impressive Webs</a></h2>
<p>Not very customizable (just click to see the code) but probably the most thorough on the list as far as number of effects covered.</p>
<div class="tutorialimage"><a href="http://www.impressivewebs.com/css3-click-chart/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-1.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://css-tricks.com/examples/ButtonMaker/">CSS-Tricks Button Maker</a></h2>
<p>An excellent little button maker from Internet wiz Chris Coyier. Just use the sliders to change the properties.</p>
<div class="tutorialimage"><a href="http://css-tricks.com/examples/ButtonMaker/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-2.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://border-radius.com/">Border Radius</a></h2>
<p>One of the more elegant options for setting a border radius. Just type in a single number and it does the rest.</p>
<div class="tutorialimage"><a href="http://border-radius.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-8.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://www.fontsquirrel.com/fontface/generator">Font Squirrel @Font-Face Kit Generator</a></h2>
<p>This is by far my favorite tool on the list. Upload a font and this will spit out everything you need to embed it into a website including HTML, CSS and multiple font file formats. You&#8217;ll definitely want to bookmark this one!</p>
<div class="tutorialimage"><a href="http://www.fontsquirrel.com/fontface/generator"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-9.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://westciv.com/">Westciv</a></h2>
<p>Westciv has a number of useful CSS3 generators that are both free and easy to use. Check them out below.</p>
<div class="tutorialimage"><a href="http://westciv.com/tools/gradients/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-3.jpg" alt="screenshot" width="510"/></a></div>
<ul>
<li><a href="http://westciv.com/tools/gradients/">CSS3 Gradients</a></li>
<li><a href="http://westciv.com/tools/shadows/">CSS3 Text Shadows</a></li>
<li><a href="http://westciv.com/tools/transforms/index.html">CSS3 Transforms</a></li>
<li><a href="http://westciv.com/tools/textStroke/index.html">CSS3 Text Stroke</a></li>
<li><a href="http://westciv.com/tools/radialgradients/index.html">CSS3 Radial Gradients</a></li>
<li><a href="http://westciv.com/tools/boxshadows/index.html">CSS3 Box Shadows</a></li>
</ul>
<h2><a href="http://gradients.glrzad.com/">CSS3 Gradient Generator</a></h2>
<p>Use a few simple dropdowns and a slider help create complex gradients.</p>
<div class="tutorialimage"><a href="LINK"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-6.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://www.widgetpad.com/694/">Widgetpad CSS3 Generator</a></h2>
<p>Another one with several properties and effects to choose from.</p>
<div class="tutorialimage"><a href="http://www.widgetpad.com/694/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-7.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://border-image.com/">Border Image</a></h2>
<p>Border-image is a rather complicated new CSS3 feature. Figure out how it all works using this tool.</p>
<div class="tutorialimage"><a href="http://border-image.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-10.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://dryicons.com/blog/2010/07/15/css3-gradient-button-generator/">Dry Icons Button Generator</a></h2>
<p>An awesome button generator with a ton of options. </p>
<div class="tutorialimage"><a href="http://dryicons.com/blog/2010/07/15/css3-gradient-button-generator/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-11.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://csscorners.com/">CSS Corners</a></h2>
<p>This one currently handles gradients and rounded corners and promises more options on the way soon.</p>
<div class="tutorialimage"><a href="http://csscorners.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-12.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://www.css3maker.com/">CSS3 Maker</a></h2>
<p>Super slick and easy to use, this one handles quite a few CSS tricks.</p>
<div class="tutorialimage"><a href="http://www.css3maker.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-13.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://www.cssportal.com/css3-rounded-corner/">CSS3 Rounded Corner Generator</a></h2>
<p>Yet another basic rounded corner generator.</p>
<div class="tutorialimage"><a href="http://www.cssportal.com/css3-rounded-corner/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-14.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://css3menu.com/index.html#download">CSS3 Menu Generator</a></h2>
<p>This one is actually a full-fledged downloadable application for creating complex CSS3 menus with rounded corners, gradients, and more.</p>
<div class="tutorialimage"><a href="http://css3menu.com/index.html#download"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-15.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://debray.jerome.free.fr/index.php?outils/Generateur-de-multi-colonnes-en-css3">CSS3 Column Generator</a></h2>
<p>One of the few column generators I could find (CSS3 Generator also does columns). This one isn&#8217;t in English but is still easy enough to figure out and the code it spits out is of course fully readable.</p>
<div class="tutorialimage"><a href="http://debray.jerome.free.fr/index.php?outils/Generateur-de-multi-colonnes-en-css3"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-16.jpg" alt="screenshot" width="510"/></a></div>
<h2><a href="http://freehtml5templates.com/gradientgenerator/gradient-generator.php">Quick 3-Color CSS3 Gradient Generator</a></h2>
<p>One last CSS gradients generator, just in case the 10 or so above don&#8217;t satisfy your gradient craving.</p>
<div class="tutorialimage"><a href="http://freehtml5templates.com/gradientgenerator/gradient-generator.php"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/css3-gen-17.jpg" alt="screenshot" width="510"/></a></div>
<h2>Conclusion</h2>
<p>I hope the tools above help you learn to be a CSS3 master. For even more CSS3 goodness check out <a href="http://css-infos.net/">CSS-Infos</a> and <a href="http://css3pie.com/">CSS3 Pie</a>. CSS-Infos is a huge list of CSS properties along with what browsers support them and CSS3 Pie is a resource for getting good old IE to display CSS3 properly.</p>
<p>Leave a comment below and let us know what your favorite CSS generators are and if we left any out. </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/20-free-css3-code-generators/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>10 Amazing Examples of Innovative CSS3 Animation</title>
		<link>http://designshack.net/articles/css/10-amazing-examples-of-innovative-css3-animation/</link>
		<comments>http://designshack.net/articles/css/10-amazing-examples-of-innovative-css3-animation/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 16:09:00 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[css3]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=4525</guid>
		<description><![CDATA[CSS3 has brought about a number of aesthetically impressive new features. Perhaps the most fun of these to play with is CSS animation, which allows you to perform many motion-based functions normally delegated to JavaScript. Join me on my epic quest to discover the coolest, most innovative, and more importantly, nerdiest use of CSS animation [...]]]></description>
			<content:encoded><![CDATA[<p>CSS3 has brought about a number of aesthetically impressive new features. Perhaps the most fun of these to play with is <a href="http://www.w3.org/TR/css3-animations/">CSS animation</a>, which allows you to perform many motion-based functions normally delegated to JavaScript. Join me on my epic quest to discover the coolest, most innovative, and more importantly, nerdiest use of CSS animation on the web. Begin!</p>
<p><span id="more-4525"></span></p>
<p>Warning: These animations are pretty browser specific, so if you&#8217;re surfing in IE6, it&#8217;s time to stop watching Saved By The Bell, ditch the dial-up connection and download a <a href="http://www.apple.com/safari/">modern browser</a>. </p>
<p><!-- One --></p>
<h2><a href="http://24ways.org/2009/going-nuts-with-css-transitions">Rotating Polaroids</a></h2>
<div class="tutorialimage"><a href="http://24ways.org/2009/going-nuts-with-css-transitions"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-polaroid.jpg" alt="screenshot" width="510"/></a></div>
<p>This tutorial shows you how to create an amazing, animated pile of photographs utilizing a ton of new CSS3 commands. We&#8217;re off to a strong start, this one will be hard to beat.</p>
<p><strong><a href="http://media.24ways.org/2009/14/3/index.html">Click to View Demo</a></strong></p>
<p><!-- Two --></p>
<h2><a href="http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/">The Matrix</a></h2>
<div class="tutorialimage"><a href="http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-matrix.jpg" alt="screenshot" width="510"/></a></div>
<p>Follow the white rabbit.. err I mean, check out this awesome Matrix animation. Not quite true to the movie (the individual characters don&#8217;t change), but impressive nonetheless. Seeing as how The Matrix is one of the best sci-fi flicks of all time (I&#8217;m talking about the first movie, not those other two disasters), this one is going to jump to the top of our list and no doubt stay there for a while until a worthy competitor can be found.</p>
<p><strong><a href="http://girliemac.com/sandbox/matrix.html">Click to View Demo</a></strong></p>
<p><!-- Three --></p>
<h2><a href="http://webkit.org/blog-files/3d-transforms/poster-circle.html">Trippy Spinning Column of Fun</a></h2>
<div class="tutorialimage"><a href="http://webkit.org/blog-files/3d-transforms/poster-circle.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-column.jpg" alt="screenshot" width="510"/></a></div>
<p>This crazy animation features a spinning column made up of rotating rows of colored boxes and text. The overall effect is crazy cool and undeniably dizzying. This one is a little too cracked out to steal the thunder from The Matrix though, the champion remains.<br />
<em>Tip: For an increased chance of motion sickness, scroll up and down and shake your head back and forth while watching the animation (we are in no way responsible for any ruined hardware you possess after tossing your lunch all over your desk).</em></p>
<p><strong><a href="http://webkit.org/blog-files/3d-transforms/poster-circle.html">Click to View Demo</a></strong></p>
<p><!-- Four --></p>
<h2><a href="http://www.marcofolio.net/webdesign/jquery_dj_hero_css3_and_jquery_fun.html">DJ Hero</a></h2>
<div class="tutorialimage"><a href="http://www.marcofolio.net/webdesign/jquery_dj_hero_css3_and_jquery_fun.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-djhero.jpg" alt="screenshot" width="510"/></a></div>
<p>This tutorial combines CSS3 and jQuery to create spinning records. Using the on-screen controls, you can control the speed of the records or simply grab a record with your mouse to lay down some groovy scratches.<br />
Virtual turntables on a vintage wooden background? This could be a pretty major competitor folks, this debate is heating up. Go ahead, click it. You know you want to play.</p>
<p><strong><a href="http://demo.marcofolio.net/jquery_dj/">Click to View Demo</a></strong></p>
<p><!-- Five --></p>
<h2><a href="http://www.fofronline.com/2009-07/animated-css3-cube-interface-using-3d-transforms/">3D Animated Cube</a></h2>
<div class="tutorialimage"><a href="http://www.fofronline.com/2009-07/animated-css3-cube-interface-using-3d-transforms/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-cube.jpg" alt="screenshot" width="510"/></a></div>
<p>This one lets you use the arrow keys to control the rotation of a 3D cube. At first I thought it was pretty lame but then I realized you could hold down the arrow keys to make it freak out and go into turbo spinning death mode, which obviously redeemed it a bit. Mega style points for including <a href="http://en.wikipedia.org/wiki/Sonic_the_Hedgehog_(character)">Sonic The Hedgehog</a> as well.</p>
<p><strong><a href="http://www.fofronline.com/experiments/cube-3d/">Click to View Demo</a></strong></p>
<p><!-- Six --></p>
<h2><a href="http://www.the-art-of-web.com/css/css-animation/">Rocket Ship</a></h2>
<div class="tutorialimage"><a href="http://www.the-art-of-web.com/css/css-animation/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-rocket.jpg" alt="screenshot" width="510"/></a></div>
<p>A rocket ship no doubt brought to you by the wonders of MS-Paint flies across the sky with breathtaking speed. Sort of&#8230; In reality it sort of floats along, transported by a strange, rectangular forcefield with dotted lines. About halfway through the animation the rocket practically disappears for no apparent reason so it&#8217;s obviously a top-secret high-tech stealth rocket with armed a cloaking device to ward off invading Vulcan destroyers.<br />
Not exactly a serious competitor. In fact, why did I even show this to you? And even more pertinent, is there such a thing as a Vulcan destroyer or did I just make that up? </p>
<p><strong><a href="http://www.the-art-of-web.com/css/css-animation/">Click to View Demo</a></strong></p>
<p><!-- Seven &#038; Eight --></p>
<h2>Weather</h2>
<h3><a href="http://natbat.net/code/clientside/css/snowflakes/">Snow</a></h3>
<div class="tutorialimage"><a href="http://natbat.net/code/clientside/css/snowflakes/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-snow.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://webkit.org/blog-files/leaves/index.html">Leaves</a></h3>
<div class="tutorialimage"><a href="http://webkit.org/blog-files/leaves/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-leaves.jpg" alt="screenshot" width="510"/></a></div>
<p>Let&#8217;s knock all the weather stuff out in one go shall we? Where there is cheesy animation, there also is the inevitable falling snow, leaves, rain, etc. Don&#8217;t get me wrong, these are pretty cool and could lead to some really excellent seasonal website modifications. However, these particular executions, though well made, aren&#8217;t that creative with context. Let me know if you create a website that has giant hailstones destroying all the content on the page, now that would be something.</p>
<p><strong><a href="http://natbat.net/code/clientside/css/snowflakes/">Click to View Snow Demo</a></strong><br />
<strong><a href="http://webkit.org/blog-files/leaves/index.html">Click to View Leaves Demo</a></strong></p>
<p><!-- Nine --></p>
<h2><a href="http://paulbakaus.com/2008/05/31/coverflow-anyone/">Cover Flow</a></h2>
<div class="tutorialimage"><a href="http://paulbakaus.com/2008/05/31/coverflow-anyone/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/coverflow.jpg" alt="screenshot" width="510"/></a></div>
<p>This animation mimics Apple&#8217;s <a href="http://en.wikipedia.org/wiki/Cover_Flow">cover flow</a> using a hybrid CSS/jQuery technique like the DJ Hero example above. By imitating Apple this one performs well in both the cool and nerdy categories and also does a bang up job at being innovative (this is the only CSS3 Cover Flow fake I could find). We&#8217;ve got yet another contender on our hands.</p>
<p><strong><a href="http://paulbakaus.com/lab/js/coverflow/">Click to View Demo</a></strong></p>
<p><!-- Last --></p>
<h2><a href="http://blog.gesteves.com/post/261593774/im-done-star-wars-opening-crawl-using-only-html">Star Wars Crawl</a></h2>
<div class="tutorialimage"><a href="http://blog.gesteves.com/post/261593774/im-done-star-wars-opening-crawl-using-only-html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/CA-starwars.jpg" alt="screenshot" width="510"/></a></div>
<p>That&#8217;s it, game over. I&#8217;d like to thank the other entrants for playing, but this one takes the prize. It&#8217;s the opening scene from freakin&#8217; Star Wars for crying out loud&#8230; in HTML and CSS (that&#8217;s live text you&#8217;re looking at fool). I ask you, what better use of CSS animation could there possibly be? I submit that there is none. Trust me, show this to your nerdiest friend and he will magically transform into a 4 year old on Christmas morning.</p>
<p><strong><a href="http://www.gesteves.com/experiments/starwars.html">Click to the Epic View Demo</a></strong><br />
(Safari + Snow Leopard Required)</p>
<h2>Conclusion</h2>
<p>For those of you that think this contest was rigged, you&#8217;re right. I made up the contest idea after finding the Star Wars example just to highlight how much everything else paled by comparison. The real intent of the article is to show you that there&#8217;s no end to the cool stuff you can build with the relatively simple animation features built into CSS3.<br />
Use the comments below to let us know which was your favorite. Also, if you know of any other examples, please share them!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/10-amazing-examples-of-innovative-css3-animation/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
		<item>
		<title>The Impact of Firefox 3</title>
		<link>http://designshack.net/articles/the-impact-of-firefox-3/</link>
		<comments>http://designshack.net/articles/the-impact-of-firefox-3/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 11:37:37 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[3]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=165</guid>
		<description><![CDATA[Since it&#8217;s first release in November 2004, Firefox has come a phenomenally long way. Market share has sky rocketed, and a huge community has built up offering extensions and add on software. The third incarnation of Firefox offers something for web developers as well as users, continuing along their previous path of adhering to web [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.designshack.net/postimages/firefox_logo.jpg" alt="Firefox Logo" class="right" /></p>
<p>Since it&#8217;s first release in November 2004, Firefox has come a phenomenally long way. Market share has sky rocketed, and a huge community has built up offering extensions and add on software. The third incarnation of Firefox offers something for web developers as well as users, continuing along their previous path of adhering to web standards and supporting the latest technologies.</p>
<p>This article will outline how important it is that your site is suitable for Firefox users, and explain the new features which the browser makes available to designers.</p>
<p>The following chart shows the percentage of users visiting Design Shack from various browsers. It is plain to see the importance of the site displaying correctly in Firefox and offering a great browsing experience to users of that browser:</p>
<p><img src="http://www.designshack.net/postimages/browsershare.jpg" alt="Design Shack Browser Share" /></p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/the-impact-of-firefox-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to CSS3 &#8211; Part 6: Backgrounds</title>
		<link>http://designshack.net/articles/introduction-to-css3-part-6-backgrounds/</link>
		<comments>http://designshack.net/articles/introduction-to-css3-part-6-backgrounds/#comments</comments>
		<pubDate>Tue, 27 May 2008 16:12:35 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[back]]></category>
		<category><![CDATA[backgrounds]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[ground]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[origin]]></category>
		<category><![CDATA[resizing]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=179</guid>
		<description><![CDATA[For the last part of our introductory series to CSS3, we will be taking a look at the new background properties. These include background size, using more than one background for an element, and background origin (which effects the position of a background). The new features allow greater control of the background element and will [...]]]></description>
			<content:encoded><![CDATA[<p>For the last part of our introductory series to CSS3, we will be taking a look at the new background properties. These include background size, using more than one background for an element, and background origin (which effects the position of a background).</p>
<p>The new features allow greater control of the background element and will provide designers with a whole array of new possibilities.  As usual, examples can be found below:</p>
<p><a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html" class="smallbox">View the live examples page</a></p>
<h2>Background Size</h2>
<p>Before CSS3, background size was determined by the actual size of the image used. It will be possible with the next CSS revision to specify in terms of percentage or pixels how large a background image should be. This will allow you to re-use images in several different contexts and also expand a background to fill an area more accurately.</p>
<p>The following is a simple example of resizing the Design Shack logo as a background in the top left hand area of a div:</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="css" style="font-family:monospace;"><span style="color: #6666ff;">.backgroundsize</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">http://www.designshack.net/images/logo.gif</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
-webkit-background-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">137px</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
-khtml-background-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">137px</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
-o-background-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">137px</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
background-<span style="color: #000000; font-weight: bold;">size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">137px</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddccb5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/backgroundresize.gif" alt="CSS3 Background Resizing" /></p>
<h2>Multiple Backgrounds</h2>
<p>The new ability to use multiple backgrounds is a great time saver, allowing you to achieve effects which previously required more than one <code>div</code>. Whether it will be possible to combine this with <code>background-size</code> will be interesting to see.</p>
<p>The example below uses one background for the top border, one repeated vertically for the left and right borders and a third at the bottom.</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="css" style="font-family:monospace;"><span style="color: #6666ff;">.multiplebackgrounds</span> <span style="color: #00AA00;">&#123;</span> 
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">270px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span> <span style="color: #933;">20px</span> <span style="color: #933;">20px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">top.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">,</span>
<span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">bottom.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">,</span>
<span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">middle.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">repeat-y</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/multiplebackgrounds.gif" alt="CSS3 Multiple Backgrounds" /></p>
<h2>Background Origin</h2>
<p>CSS3 allows you to specify how the position of a background is calculated. The <code>background-origin</code> property can be set to start positioning from either the <code>border</code>, <code>padding</code>, or <code>content</code>. This allows for greater flexibility in terms of placing a background image.</p>
<h2>In conclusion&#8230;</h2>
<p>There are a whole new variety of background options available with CSS3. As with all the other modules covered in this introductory series, it leads to greater flexibility and makes it much easier to recreate previously complex effects. Whilst not supported by most browsers as yet, it shouldn&#8217;t be too long before you can get creating stunning user interfaces with these new additions.</p>
<p>We really hope that you have enjoyed this series, and we&#8217;ll be keeping you up to date on all the latest CSS3 developments as they happen over coming months. Here&#8217;s looking forward to the next generation of style sheets!</p>
<h2>Other posts in the series</h2>
<ul>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-1-what-is-it">Introduction to CSS3 &#8211; Part 1: What is it?</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-2-borders">Introduction to CSS3 &#8211; Part 2: Borders</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-3-text-effects">Introduction to CSS3 &#8211; Part 3: Text Effects</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-4-user-interface">Introduction to CSS3 &#8211; Part 4: User Interface</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-5-multiple-columns">Introduction to CSS3 &#8211; Part 5: Multiple Columns</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-6-backgrounds">Introduction to CSS3 &#8211; Part 6: Backgrounds</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/introduction-to-css3-part-6-backgrounds/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Introduction to CSS3 &#8211; Part 5: Multiple Columns</title>
		<link>http://designshack.net/articles/introduction-to-css3-part-5-multiple-columns/</link>
		<comments>http://designshack.net/articles/introduction-to-css3-part-5-multiple-columns/#comments</comments>
		<pubDate>Mon, 19 May 2008 16:19:22 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[multicolumn]]></category>
		<category><![CDATA[multiple]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=185</guid>
		<description><![CDATA[Multiple columns are a major facet of laying out text &#8211; newspapers have used them for decades. So important are they that it is amazing that the current way to achieve a multi column layout is one of the most complex techniques for a new designer to grasp. CSS3 introduces a new module known, appropriately, [...]]]></description>
			<content:encoded><![CDATA[<p>Multiple columns are a major facet of laying out text &#8211; newspapers have used them for decades. So important are they that it is amazing that the current way to achieve a multi column layout is one of the most complex techniques for a new designer to grasp.</p>
<p>CSS3 introduces a new module known, appropriately, as multi-column layout. It allows you to specify how many columns text should be split down into and how they should appear. As usual, examples can be found below:</p>
<p><a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html" class="smallbox">View the live examples page</a></p>
<h2>Multiple columns using CSS3</h2>
<p>At present, this feature is available in Firefox and Safari 3. When the module becomes finalised in the CSS3 specification it will be adopted by other browsers and rolled into their updates.</p>
<p>There are four properties which relate to the multiple column layout in CSS3, allowing you to set the number of columns, width, gap between each column and a border between each:</p>
<ul>
<li>column-count</li>
<li>column-width</li>
<li>column-gap</li>
<li>column-rule</li>
</ul>
<p>At present, a browser specific selector is also needed to identify whether Safari or Firefox should display the selector. The code to be used to create a two column layout with a 1px rule between columns would be:</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="css" style="font-family:monospace;"><span style="color: #6666ff;">.multiplecolumns</span> <span style="color: #00AA00;">&#123;</span>
-moz-column-<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">130px</span><span style="color: #00AA00;">;;</span>
-webkit-column-<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">130px</span><span style="color: #00AA00;">;</span>
-moz-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
-webkit-column-gap<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
-moz-column-rule<span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddccb5</span><span style="color: #00AA00;">;</span>
-webkit-column-rule<span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddccb5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/multiplecolumns.png" alt="Multiple columns using CSS3" /></p>
<h2>Spanning columns</h2>
<p>It could also be the case that you would like an element to span more than one column &#8211; a heading, table or image for instance. This is facilitated in the specification through the use of:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">h2 <span style="color: #00AA00;">&#123;</span>
column-span<span style="color: #00AA00;">:</span> all
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Numbers can also be used to allow the element to span a certain number of columns. At present this feature isn&#8217;t implemented in any major browsers, but should provide much needed additional flexibility when designing around this feature. It would allow you to achieve effects such as:</p>
<p><img src="http://www.designshack.net/postimages/multiplecolumns_heading.jpg" alt="Multiple column span using CSS3" /></p>
<h2>In the meantime</h2>
<p>It could still be a while before this feature is supported on enough systems to allow widespread use. A List Apart published in 2005 a <a href="http://www.alistapart.com/articles/css3multicolumn">JavaScript implementation of this capability</a> which allows you to use selectors in the same way and offers support in all major browsers. It should also degrade nicely when the feature is widely adopted and the JavaScript is no longer needed. It is a great interim solution if you&#8217;re desperate for multiple columns on your site.</p>
<h2>In conclusion&#8230;</h2>
<p>Multiple column layout will save a huge headache for many designers, allowing greater control of how copy is displayed. You can read the full specification for multi-column at the <a href="http://www.w3.org/TR/css3-multicol/">W3 site</a> if you&#8217;d like more information about the feature.</p>
<p>The next, and final, article in this series will be looking at the different background features available in CSS3 including using more than one background for an element, and specifying the size of backgrounds. Remember, to see live examples of these features, take a look at our <a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html">CSS3 example page</a>.</p>
<h2>Other posts in the series</h2>
<ul>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-1-what-is-it">Introduction to CSS3 &#8211; Part 1: What is it?</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-2-borders">Introduction to CSS3 &#8211; Part 2: Borders</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-3-text-effects">Introduction to CSS3 &#8211; Part 3: Text Effects</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-4-user-interface">Introduction to CSS3 &#8211; Part 4: User Interface</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-5-multiple-columns">Introduction to CSS3 &#8211; Part 5: Multiple Columns</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-6-backgrounds">Introduction to CSS3 &#8211; Part 6: Backgrounds</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/introduction-to-css3-part-5-multiple-columns/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Introduction to CSS3 &#8211; Part 4: User Interface</title>
		<link>http://designshack.net/articles/introduction-to-css3-part-4-user-interface/</link>
		<comments>http://designshack.net/articles/introduction-to-css3-part-4-user-interface/#comments</comments>
		<pubDate>Tue, 13 May 2008 16:22:02 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[boxsizing]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[outline]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=191</guid>
		<description><![CDATA[This tutorial will be taking a look at some of the new ways you can manipulate user interface features in CSS3. But what do we mean by &#8220;user interface&#8221;? CSS3 brings some great new properties relating to resizing elements, cursors, outlining, box layout and more. We&#8217;re focusing on three of the most significant user interface [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will be taking a look at some of the new ways you can manipulate user interface features in CSS3. But what do we mean by &#8220;user interface&#8221;?</p>
<p>CSS3 brings some great new properties relating to resizing elements, cursors, outlining, box layout and more. We&#8217;re focusing on three of the most significant user interface enhancements in this tutorial.</p>
<p>The examples shown below can be seen at our CSS3 examples page. Many, however, can only be appreciated in the latest builds of various browsers:</p>
<p><a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html" class="smallbox">View the live examples page</a></p>
<h2>Resizing</h2>
<p>The latest version of Safari has <a href="http://www.apple.com/safari/">a feature</a> which allows resizable text areas. This is a great addition and one I find myself using daily. CSS3 allows you to easily apply this to any element, eventually to become cross-browser compatible. The code is the <code>resize:both;</code> line:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.ui_resizable</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;">20px</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: #00AA00;">;</span>
resize<span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/ui_resizable.png" alt="CSS3 Resizing" /></p>
<h2>Box Sizing</h2>
<p>The &#8216;box model&#8217; CSS3 module is one of the more extensive areas, and full information can be <a href="http://www.w3.org/TR/CSS2/box.html">found at the official specification</a>. The box sizing aspect allows you to define certain elements to fit an area in a certain way. For example, if you&#8217;d like two bordered boxes side by side, it can be achieved through setting box-sizing to &#8216;border-box&#8217;. This forces the browser to render the box with the specified width and height, and place the border and padding inside the box.</p>
<p>At present, additional prefixes are required to support this in all browsers &#8211; you can see the full list on the example page&#8217;s code. Here&#8217;s a basic possibility:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.area</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;">300px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddccb5</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.boxes</span> <span style="color: #00AA00;">&#123;</span>
box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</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;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#897048</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/ui_boxsizing.png" alt="CSS3 Box Sizing" /></p>
<h2>Outline</h2>
<p>Setting an element outline is already available in CSS2, but in CSS3 includes the facility to offset the outline away from the element &#8211; by a value you define. It differs from a border in two ways:</p>
<ul>
<li>Outlines do not take up space</li>
<li>Outlines may be non-rectangular</li>
</ul>
<p>They can be created as follows:</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="css" style="font-family:monospace;"><span style="color: #6666ff;">.ui_outline</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;">150px</span><span style="color: #00AA00;">;</span> 
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#897048</span><span style="color: #00AA00;">;</span>
outline-offset<span style="color: #00AA00;">:</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><img src="http://www.designshack.net/postimages/ui_outline.png" alt="CSS3 Outline Offset" /></p>
<h2>In conclusion&#8230;</h2>
<p>These features aren&#8217;t revolutionary, and are not likely to cause a stir in the design community. It can&#8217;t be denied that they&#8217;re useful &#8211; in particular giving the reader the ability to resize elements.</p>
<p>The next article in this series will be looking more in-depth at one much more revolutionary feature of CSS3 &#8211; multi column text. Remember, to see live examples of these features, take a look at our <a href="http://www.designshack.net/tutorialexamples/css3/css3examples.html">CSS3 example page</a>.</p>
<h2>Other posts in the series</h2>
<ul>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-1-what-is-it">Introduction to CSS3 &#8211; Part 1: What is it?</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-2-borders">Introduction to CSS3 &#8211; Part 2: Borders</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-3-text-effects">Introduction to CSS3 &#8211; Part 3: Text Effects</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-4-user-interface">Introduction to CSS3 &#8211; Part 4: User Interface</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-5-multiple-columns">Introduction to CSS3 &#8211; Part 5: Multiple Columns</a></li>
<li><a href="http://designshack.net/tutorials/introduction-to-css3-part-6-backgrounds">Introduction to CSS3 &#8211; Part 6: Backgrounds</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/introduction-to-css3-part-4-user-interface/feed/</wfw:commentRss>
		<slash:comments>25</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 946/1117 objects using disk: basic

Served from: designshack.net @ 2012-02-09 15:23:59 -->
