<?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; CSS</title>
	<atom:link href="http://designshack.net/tag/css/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>Convert a Pricing Table PSD to HTML and CSS</title>
		<link>http://designshack.net/articles/css/csspricingtables/</link>
		<comments>http://designshack.net/articles/css/csspricingtables/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 06:00:37 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[pricing table]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=29263</guid>
		<description><![CDATA[Today we&#8217;re going to grab some PSD pricing tables from Design Curate and try to convert them to pure CSS so you can easily drop them into your site. It&#8217;ll be a super basic but fun exercise in bringing a static design to the web and you&#8217;ll learn plenty of fun stuff along the way [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-0.jpg" alt="screenshot" width="510"/></div>
<p>Today we&#8217;re going to grab some PSD pricing tables from <a href="http://designcurate.com/resource/pricing-tables">Design Curate</a> and try to convert them to pure CSS so you can easily drop them into your site. </p>
<p>It&#8217;ll be a super basic but fun exercise in bringing a static design to the web and you&#8217;ll learn plenty of fun stuff along the way such as how to style hr tags a create a superscript effect.</p>
<p><span id="more-29263"></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>Original Design</h2>
<p>The design of our pricing tables is super minimal. They&#8217;re basically just a rounded corner rectangle with some text and buttons. Download the original PSD <a href="http://designcurate.com/resource/pricing-tables">here</a> for a closer look (we&#8217;re scrapping the Best Value banner).</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-1.jpg" alt="screenshot" width="510"/></div>
<p>As you can see, the primary task here will merely be shuffling elements into place. The top bar may seem like it&#8217;ll be tricky, but in reality it&#8217;s a cinch. More interesting from my perspective is how to style that thin dividing line and pulling off a superscript in the text. </p>
<p>Also of interest is the fact that the center pricing table is a little larger than the others and overlaps them. This could mean styling two unique versions of the table, but we&#8217;ll use a nice little trick that takes all the effort out of this. Let&#8217;s jump in and get started.</p>
<h2>Basic Shape</h2>
<p>To begin, we&#8217;ll focus on creating one pricing table. Once we have that one built, we can expand it into three fairly easily. Our first step is to create the basic shape of a single table: a vertical rectangle with rounded corners.</p>
<p>We&#8217;ll start with a div that will hold all the code for one pricing table. Assign the class of &#8220;pricingtable&#8221; so that we can easily reuse this element again later. </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;pricingtable&quot;</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 add some style. Our pricing tables will be white so I set a gray background color to help them stand out. Then I applied some sizing to our class, rounded the corners and added a shadow.</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;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ededed</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.pricingtable</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;">250px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">450px</span><span style="color: #00AA00;">;</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>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
&nbsp;
  -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>
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">9px</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.3</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;">9px</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.3</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;">9px</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.3</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>
<h3>Progress Update</h3>
<p>This step should give you a simple white box. Make sure that your dimensions are correct and that your shadow and rounded corners are functioning properly. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-2.jpg" alt="screenshot" width="510"/></div>
<h2>Top Bar</h2>
<p>Now that we&#8217;ve got our basic shape in place, we&#8217;ll start at the top and work our way down. The first thing that we need is obviously that colored bar at the top that holds the name for each of our pricing plans: Basic, Pro and Premium. To pull this off, create another div with the class of &#8220;top&#8221;. Don&#8217;t worry, we&#8217;re not going div crazy, this will be the last one that we need for our base pricing table template.</p>
<p>Inside the div, place an h2 (we&#8217;ll use the h1 later) with the name of the pricing table. We could simply use this h2 without the div to create the top bar, but structuring it this way makes it easier to add a sub tag or other content here later. </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;pricingtable&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;top&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Basic<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: #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>Turning that div into our top bar is pretty simple. To start, we give it a width of 250px, a height of 50px and sample the PSD to get a background color of #2F2E35. Then we apply the same border-radius that we used before (10px), only this time we apply it to only the top two corners, leaving the bottom corners square. </p>
<p>Next it&#8217;s time to target the h2 and give it some styling. I simply changed the color to white, aligned the text to the center and used some fancy font shorthand to set the weight, size, line-height and font-family for our headline. </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;">top</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;">250px</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;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#2F2E35</span><span style="color: #00AA00;">;</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
     -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
          border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</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: #000000; font-weight: bold;">top</span> h2 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-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: #cc66cc;">300</span> <span style="color: #933;">30px</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: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Progress Update</h3>
<p>Our plain white box is already starting to look like the pricing table we&#8217;re going for. Now we just fill in the center contents and we&#8217;ll be ready to go.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-3.jpg" alt="screenshot" width="510"/></div>
<h2>Features</h2>
<p>Moving down the table, next we find a list of features. Right away that sentence should give you a hint as to how we can mark this section up: with a list. The order isn&#8217;t anything specific here so we&#8217;ll use an unordered list.</p>
<p>Notice that in our original design, the first word of each feature is bolded. We&#8217;ll toss in some strong tags to help us pull this off in our design. </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;pricingtable&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;top&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Basic<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>25GB<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> of Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&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>Styling up this list is quite easy. To start, we want to ditch the bullet points, so set the list-style-type to &#8220;none&#8221;. After that, I use the same font shorthand as above but this time with a different size and line-height.</p>
<p>Notice that the line-height is set without a unit of measure (2, not 2px). This is a simple multiplier that takes the font-size into account (18px * 2 = 36px line-height). You can read more about this technique <a href="http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/">here</a>.</p>
<p>To finish off this block of styles, target those strong tags and be sure that they&#8217;re set to bold. </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;">.pricingtable</span> ul <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">300</span> <span style="color: #933;">18px</span>/<span style="color: #cc66cc;">2</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;">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;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.pricingtable</span> ul strong <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>Progress Update</h3>
<p>Our feature list is looking perfect! Those bolder styles really help you focus on the important pieces of information. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-4.jpg" alt="screenshot" width="510"/></div>
<h2>Dividing Line</h2>
<p>In the original design, there&#8217;s a subtle line that separates the feature list from the price. This can be accomplished with a simple horizontal rule tag:</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;pricingtable&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;top&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Basic<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>25GB<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> of Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #66cc66;">/</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 default styling for the horizontal line is <em>close</em> to what we want, but not quite there. For instance, notice that it stretches all the way across the pricing table. We actually want it narrower and centered.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-5.jpg" alt="screenshot" width="510"/></div>
<p>Styling an hr can be tricky and frustrating if you don&#8217;t know what you&#8217;re doing. You&#8217;d think that all we would have to do is set the width and color and we&#8217;d be good to go, but that&#8217;s not the case.</p>
<p>By default, certain browsers apply some weird styles that you have to clear. To be sure we get the look we want, we have to clear the borders, declare both a height and width, and set a background color. Then we center it using basic math: if our table is 250px wide and our line is 190px, that leaves 60px of width left. Using margins, we cut that value in half and assign thirty pixels of space to the left side of the line.</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;">.pricingtable</span> hr <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>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#BCBEC0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#BCBEC0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">190px</span><span style="color: #00AA00;">;</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;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Progress Update</h3>
<p>With that bit of styling, our little line is looking exactly like we want it to. Feel free to experiment with your hr to see what sort of fancy styles you can make. CSS-Tricks has some <a href="http://css-tricks.com/simple-styles-for-horizontal-rules/">great examples</a> for inspiration.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-6.jpg" alt="screenshot" width="510"/></div>
<h2>Price</h2>
<p>Next up is the price tag. This comes in two parts, the big price and the small text underneath that says &#8220;per month.&#8221; The tricky part is that, in the original design, the dollar sign is superscript. </p>
<p>I wanted to be semantic about this so I went ahead and used the &#8220;sup&#8221; tag. Some sources seem to think that this is a deprecated tag, but as far as I can tell, that&#8217;s not the case. Both sub and sup appear to be valid in HTML5 and have plenty of browser support across the board. I&#8217;m open to opposing arguments here, so let me know in the comments if you disagree.</p>
<p>Another potential point for a huge semantic argument here is my use of h1. Some would no doubt reserve h1 for the plan title at the top, but the price point here seemed to be the most important piece of information (importance trumps order), so I thought it was best to utilize it here. Once again, feel free to disagree and go your own way. </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;pricingtable&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;top&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Basic<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>25GB<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> of Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>$<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>25<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>per month<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>Now for our CSS we have three different things to target: the h1, the h1 sup and the paragraph. There&#8217;s nothing fancy here, just some more font-sizing and a little bit of margins to scoot things into place. Notice that all we need to do for the sup tag is reduce the font size. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.pricingtable</span> h1 <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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">88px</span>/<span style="color: #cc66cc;">1</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;">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: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.pricingtable</span> h1 sup <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.pricingtable</span> p <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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">500</span> <span style="color: #933;">14px</span>/<span style="color: #cc66cc;">1</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;">#BCBEC0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Progress Update</h3>
<p>Our pricing table is nearly complete! Thus far we&#8217;ve conquered the four most difficult pieces of the puzzle, all that&#8217;s left is to create a button at the bottom. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-7.jpg" alt="screenshot" width="510"/></div>
<h2>The Button</h2>
<p>To finish off our pricing table, let&#8217;s put a sign up button at the bottom. To accomplish this, just throw an anchor tag into your HTML. This will finish up our reusable pricingtable div.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pricingtable&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;top&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Basic<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>25GB<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> of Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>$<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>25<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>per month<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;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Sign Up<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>To turn this simple text link into a button, set the display to block and define a width and height. Also be sure to fix the default link styling by setting the color and text-decoration. I transformed the text into uppercase as well to match the original design. Finally, apply the same border-radius as before.</p>
<p>To finish off the button, you can use a solid color to keep things simple, but I opted for a basic gradient that gets lighter when you hover over it. It&#8217;s a big, scary chunk of CSS but don&#8217;t worry, it&#8217;s all fairly basic. Use a free tool like <a href="http://www.colorzilla.com/gradient-editor/">this one</a> to save you some trouble if you&#8217;re creating your own gradient.</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;">.pricingtable</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;">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;">150px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">25px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <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: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">500</span> <span style="color: #933;">16px</span>/<span style="color: #933;">40px</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>
&nbsp;
  -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;
  <span style="color: #808080; font-style: italic;">/*Gradient*/</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#9dcc55</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;">#9dcc55</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#96c23d</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;">#9dcc55</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;">#96c23d</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;">#9dcc55</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">#9dcc55</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">#9dcc55</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">#9dcc55</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">'#9dcc55'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#96c23d'</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>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.pricingtable</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#b2e560</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;">#b2e560</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#96c23d</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;">#b2e560</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;">#96c23d</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;">#b2e560</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">#b2e560</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">#b2e560</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">#b2e560</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#96c23d</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;">'#b2e560'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#96c23d'</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></pre></div></div>

</div>
<p></ br></p>
<h3>Progress Update</h3>
<p>With that, our first pricing table is complete! If we wanted to go further, we could grab a slab serif web font to make it look just like the PSD, but I like the Helvetica just fine here. Now we have to take this one item and turn it into three!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-8.jpg" alt="screenshot" width="510"/></div>
<h2>Making Three Tables</h2>
<p>To expand this into three unique tables, copy and paste the HTML that you just created so that you have three pricingtable divs and place them all inside of a container div. Then customize the text on each so that the features and price point are correct. Finally, add a &#8220;featured&#8221; class to the second table. We&#8217;ll us this to pull off the enlarged effect. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pricingtable&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;top&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Basic<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>25GB<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> of Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>$<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>25<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>per month<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;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Sign Up<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>
&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;pricingtable featured&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;top&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Pro<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>50GB<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> of Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>20<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>$<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>49<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>per month<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;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Sign Up<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>
&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;pricingtable&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;top&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Premium<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: #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;">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;">strong</span>&gt;</span>Full<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Support<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>Unlimited<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Storage<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>Unlimited<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Domains<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;&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>50<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> Email Addresses<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>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>$<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">sup</span>&gt;</span>79<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>per month<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;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Sign Up<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>
&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>To make the pricing tables appear next to each other, go back to your pricingtable class and float it left. Also apply a width of 780px to your container and center it on the page with auto left and right margins. </p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">780px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.pricingtable</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;">250px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">450px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</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>
&nbsp;
  -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>
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">9px</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.3</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;">9px</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.3</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;">9px</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.3</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 we have three pricing tables in a row, which is exactly what we want. However, remember that the center one should be larger than the other two, this is not yet the case.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-9.jpg" alt="screenshot" width="510"/></div>
<p>Instead of manually going through and adjusting each little set of dimensions throughout the center pricing table, we can target the unique class that we gave it and apply a CSS transformation to enlarge it. Since all of our content is pure code (no images), the scaled up version should look just fine.</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;">.featured</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-moz-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-o-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-ms-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1.2</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">1.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>
<h2>All Finished!</h2>
<p>With that, our CSS pricing tables are complete. The last transformation gave us exactly the effect that we wanted with the center table larger and floating over the other two. Check out the live demo versions below.</p>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/pricingtables/index.html">Click here</a> to launch demo<br />
<strong>Code:</strong> See and tweak the source code at <a href="http://dabblet.com/gist/1753915">Dabblet</a></p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/css-pricingtables-10.jpg" alt="screenshot" width="510"/></div>
<h2>Conclusion</h2>
<p>I hope you enjoyed building these pricing tables and will get some good use out of them. Use them however you wish and be sure to download the PSD and vector versions from <a href="http://designcurate.com/resource/pricing-tables">Design Curate</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/csspricingtables/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Code a Useful Expanding Vertical Navigation Menu</title>
		<link>http://designshack.net/articles/css/verticalaccordionav/</link>
		<comments>http://designshack.net/articles/css/verticalaccordionav/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 06:00:44 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[vertical]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=29230</guid>
		<description><![CDATA[Today we have yet another awesome step-by-step CSS project for you! This time around we&#8217;re going to build a super useful expanding vertical navigation menu. It&#8217;s a great way to hide a lot of links in a fairly small space and the animations will add a nice touch to your site. Even if you&#8217;re a [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-0.jpg" alt="screenshot" width="510"/></div>
<p>Today we have yet another awesome step-by-step CSS project for you! This time around we&#8217;re going to build a super useful expanding vertical navigation menu. It&#8217;s a great way to hide a lot of links in a fairly small space and the animations will add a nice touch to your site.  </p>
<p>Even if you&#8217;re a complete beginner, you should be able to pull this off. I&#8217;ll guide you along every step of the way and explain how each chunk of code works so you can implement these same techniques in future projects and deepen your understanding of CSS. Let&#8217;s get started!</p>
<p><span id="more-29230"></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>Before we start coding, it&#8217;s always helpful to lay out the rough concept of what you want to achieve so you can wrap your brain around what&#8217;s going to be involved. The item we&#8217;re building today is a vertical navigation menu that&#8217;s in a sort of modified accordion format (get a sneak peek of the finished product <a href="http://designshack.net/tutorialexamples/verticalnav/index.html">here</a>).</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-1.jpg" alt="screenshot" width="510"/></div>
<p>As you can see, the sections on the bottom are closed by default and slide open when you over over them. However, to add some nice variation we&#8217;ll also include a section that stays open all of the time. In the main section that is always open we&#8217;ll include a brief welcome message and in the sections that slide open will be sub-sections of navigation links. </p>
<p>Now that we have a good idea of where we&#8217;re going, let&#8217;s start outlining the structure in our HTML.</p>
<h2>The HTML</h2>
<p>The first thing we&#8217;re going to do is toss in some nice HTML5 to wrap the menu in. The new nav element provides a beautifully semantic container for our menu.</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;nav&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!-- all nav code here --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>nav&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>Now let&#8217;s think about how our menu is going to be structured. We&#8217;re not simply going to have a list of links, each bar represents a link with an additional area below it. We&#8217;ll wrap these up in a div. Then within each div we&#8217;ll need a main link (the colored bar) and a list of sub-links (the white area). Assuming that this item will be thrown into a site that already has some default styling, let&#8217;s arbitrarily settle on h4 for the main link and a simple unordered list for the rest.</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;nav&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;menu-item&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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>Portfolio<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;">h4</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!-- colored bar --&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!-- expanding white area --&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>&gt;</span>Web<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>&gt;</span>Print<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>&gt;</span>Other<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>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>nav&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>We can copy, paste and modify this section of code to make up the various pieces of our navigation menu. Here we have a Portfolio, About, and Contact section, each with three sub-links. Each section is given the same class (menu-item) so we can style them in one go. </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;nav&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;menu-item&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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>Portfolio<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;">h4</span>&gt;</span>
      <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>&gt;</span>Web<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>&gt;</span>Print<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>&gt;</span>Other<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>
&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;menu-item&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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;">h4</span>&gt;</span>
      <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>&gt;</span>History<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>&gt;</span>Meet The Owners<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>&gt;</span>Awards<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>
&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;menu-item&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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;">h4</span>&gt;</span>
      <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>&gt;</span>Phone<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>&gt;</span>Email<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>&gt;</span>Location<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>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>nav&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>I wanted to focus on those areas first because they&#8217;re all the same, but remember that the top section is actually different, both in functionality and content. Instead of holding an unordered list, it will hold a paragraph. We&#8217;ll also add in a unique class to make it that much easier to target in our CSS.</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;nav&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;menu-item alpha&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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;">h4</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit...<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;menu-item&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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>Portfolio<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;">h4</span>&gt;</span>
      <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>&gt;</span>Web<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>&gt;</span>Print<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>&gt;</span>Other<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>
&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;menu-item&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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;">h4</span>&gt;</span>
      <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>&gt;</span>History<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>&gt;</span>Meet The Owners<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>&gt;</span>Awards<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>
&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;menu-item&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h4</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;">h4</span>&gt;</span>
      <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>&gt;</span>Phone<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>&gt;</span>Email<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>&gt;</span>Location<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>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>nav&gt;</span></pre></div></div>

</div>
<p></ br></p>
<p>With that, we&#8217;re already finished with the HTML. Though it&#8217;s not styled at all, the live preview perfectly showcases the hierarchy of our navigation menu. Here you can clearly see our menu beginning to take form.  </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-2.jpg" alt="screenshot" width="510"/></div>
<h2>Base Styles</h2>
<p>To start off our menu styling, we need to establish a few basics. First, we&#8217;ll clear the default margins and padding. We&#8217;ll be squishing the divs right up next to each other so any default browser spacing will ruin the layout.</p>
<p>Next, we&#8217;ll apply a simple color to the background so the white portions of our menu will stand out. Then we&#8217;ll toss in some basic font styles and add a slight shadow to the menu. Note that the margin set in the nav block centers the menu on the page, this is for display purposes only and should be removed when you want to nudge the menu into place.</p>
<p>Finally, we&#8217;ll add some dimensions and background color to the nav and menu-item selectors. Here&#8217;s the resulting 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: #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: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#e5e5e7</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
nav <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: #ff0000;">&quot;Lucida Grande&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1.5</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: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*for display only*/</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>
  -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</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;">5px</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;">5px</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>
&nbsp;
<span style="color: #6666ff;">.menu-item</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>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>A this point, the preview is looking like we&#8217;ve done more harm than good, but fear not, it&#8217;ll start looking spiffy in no time.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-3.jpg" alt="screenshot" width="510"/></div>
<h2>Header Styles</h2>
<p>Now it&#8217;s time to style our h4 tags and turn them into the horizontal bars that we saw in our mockup. To do this, we just need a little padding and a background color. While we&#8217;re here we can begin to style the typography as well. We&#8217;re inheriting the font-family we set up before so we don&#8217;t need to re-type that. Instead we just need to set a size and weight. </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;">/*Menu Header Styles*/</span>
<span style="color: #6666ff;">.menu-item</span> h4 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">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;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">500</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">7px</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#a90329</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>As you can see in the image below, our link styles are still overriding some of the type styles we set here so we&#8217;ll need to go in and fix those next. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-4.jpg" alt="screenshot" width="510"/></div>
<h3>Header Links</h3>
<p>Obviously, the blue link is no good so we need to change that to white. We also want to ditch any text decoration (the underline). Now, we could stop here but the default behavior would be that only the text is clickable and not the whole bar, which is not ideal. To make the entire bar a link, we set the display property to block and the width to the full menu size (200px).</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;">.menu-item</span> h4 a <span style="color: #00AA00;">&#123;</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;">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;">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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Now our colored bar is looking much better. Here&#8217;s the preview:</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-5.jpg" alt="screenshot" width="510"/></div>
<h3>Making It Pretty</h3>
<p>If you want to stick with something simple, you can skip this step, but I&#8217;m going to trudge on and add a few more visual tweaks. Go back and modify that header style block to include a gradient and some very subtle borders. You likely won&#8217;t even be able to spot the borders until the menu is closed, but combined with the gradients they&#8217;ll really help differentiate each section so they don&#8217;t all look like one big 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: #808080; font-style: italic;">/*Menu Header Styles*/</span>
<span style="color: #6666ff;">.menu-item</span> h4 <span style="color: #00AA00;">&#123;</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> 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.3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</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: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-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;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">500</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">7px</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*Gradient*/</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#a90329</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;">#a90329</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#8f0222</span> <span style="color: #933;">44%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#6d0019</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;">#a90329</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> color-stop<span style="color: #00AA00;">&#40;</span><span style="color: #933;">44%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#8f0222</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;">#6d0019</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;">#a90329</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#8f0222</span> <span style="color: #933;">44%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">#a90329</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#8f0222</span> <span style="color: #933;">44%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">#a90329</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#8f0222</span> <span style="color: #933;">44%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">#a90329</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#8f0222</span> <span style="color: #933;">44%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">'#a90329'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#6d0019'</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>
<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.co.uk/wp-content/uploads/cssvertmenu-6.jpg" alt="screenshot" width="510"/></div>
<h3>Hover Styles</h3>
<p>Next we&#8217;re going to add a subtle hover style to the bar links. All we&#8217;re going to do is tweak the colors on the gradient a little so they get brighter when you hover.</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;">.menu-item</span> h4<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>  
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#cc002c</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;">#cc002c</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#6d0019</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;">#cc002c</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;">#6d0019</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;">#cc002c</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">#cc002c</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">#cc002c</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">#cc002c</span> <span style="color: #933;">0%</span><span style="color: #00AA00;">,</span><span style="color: #cc00cc;">#6d0019</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;">'#cc002c'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#6d0019'</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>
<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.co.uk/wp-content/uploads/cssvertmenu-7.jpg" alt="screenshot" width="510"/></div>
<h2>Paragraph Styles</h2>
<p>Remember that the first item in our menu holds a paragraph and not an unordered list, so next we&#8217;ll attack this to get it looking nice. The lists will take a sizable chunk of code but the paragraph hardly requires anything. Just define the size and color, then toss in some padding. </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;">/*First Item Styles*/</span>
<span style="color: #6666ff;">.alpha</span> p <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#aaa</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The top section is now looking great! Both the header bar and the paragraph are exactly where we need them to be.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-8.jpg" alt="screenshot" width="510"/></div>
<h2>Unordered List Styles</h2>
<p>There&#8217;s a ton of stuff that we need to do to get these lists straightened out. Let&#8217;s switch things up a bit and look at the code first, then I&#8217;ll walk you through 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: #808080; font-style: italic;">/*ul Styles*/</span>
<span style="color: #6666ff;">.menu-item</span> ul <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>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">13px</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;">30px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.menu-item</span> ul a <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#aaa</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*li Styles*/</span>
<span style="color: #6666ff;">.menu-item</span> li <span style="color: #00AA00;">&#123;</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;">#eee</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.menu-item</span> li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>As you can see, the first block targets the unordered list as a whole unit. Here I set some basic sizing and font styles and removed the bullet point by setting list-style-type to none. </p>
<p>Next I targeted the links specifically. I moved them over, removed the underlines, set the color and performed the same display:block trick that we saw before to make the clickable area larger. </p>
<p>To finish things off, I applied a few custom styles to the list items themselves. The bottom border creates a separation between each item and the hover style changes the background. Here&#8217;s the result of our labor, our menu is almost finished!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-9.jpg" alt="screenshot" width="510"/></div>
<h2>Collapse And Animate</h2>
<p>Up to this point, we&#8217;ve kept our menu opened up so that we could see it while we style the elements within. Now that we know that all of our visual styles are exactly like we want them, it&#8217;s time to collapse each section and then set them up to pop open on hover.</p>
<p>By default, browsers will set the height of those unordered lists to auto, meaning they&#8217;ll be just tall enough to hold all of the content within. To collapse the menu sections so that only the bars show, we can target those unordered lists and set the height to 0. Notice that we&#8217;re leaving the paragraph alone, this will ensure that our top section is always open.</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;">/*ul Styles*/</span>
<span style="color: #6666ff;">.menu-item</span> ul <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>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">13px</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;">30px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*Collapses the menu*/</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Now our menu is much shorter and doesn&#8217;t eat up so much space. You can also finally see the benefit of those gradients and borders that we implemented before. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-10.jpg" alt="screenshot" width="510"/></div>
<h3>Animating the Transition</h3>
<p>Next we&#8217;ll want to open these menus back up on hover, but before we do that, let&#8217;s set up an animation so the transition is nice and gradual. Make sure you insert the various browser extensions and target the height 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: #808080; font-style: italic;">/*ul Styles*/</span>
<span style="color: #6666ff;">.menu-item</span> ul <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>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">13px</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;">30px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/*Animation*/</span>
  -webkit-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">height</span> 1s ease<span style="color: #00AA00;">;</span>
     -moz-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">height</span> 1s ease<span style="color: #00AA00;">;</span>
       -o-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">height</span> 1s ease<span style="color: #00AA00;">;</span>
      -ms-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">height</span> 1s ease<span style="color: #00AA00;">;</span>
          transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">height</span> 1s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Expanding on Hover</h3>
<p>All that&#8217;s left to do now is make it so that when you hover, the ul expands. This is tricky though so be careful. Your instinct may be to do something like &#8220;ul:hover&#8221; but that&#8217;s not what we want. Instead, we want to make it so that you can hover anywhere in that menu item, either in the bar or the unordered list. However, the item that we want expanded is still only the ul. Here&#8217;s what our selector looks like:</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;">.menu-item</span><span style="color: #3333ff;">:hover </span>ul <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">93px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Sometimes reading a selector backwards is helpful when trying to figure out what it does. This tells our browser to set a height of 93px to our unordered lists when a .menu-item is hovered over.  </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/cssvertmenu-11.jpg" alt="screenshot" width="510"/></div>
<p>One important thing to note here is that we can&#8217;t just set the height to auto because for some reason this  disables the animation. If you don&#8217;t want the animation, a height of auto is much more flexible and allows you to vary the number of sub-menu items. If you want to do this with the animation, you&#8217;ll have to target the height for each individually. </p>
<h2>See It In Action</h2>
<p>Our menu is now complete. Be sure to kick the tires in the demo to see how it all works. I&#8217;ll also throw in a link to the completed code so you can have a look at it all together.</p>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/verticalnav/index.html">Launch Demo</a><br />
<strong>See the Code:</strong> Check out the HTML and CSS on <a href="http://tinkerbin.com/DDeWwqTq">Tinkerbin</a></p>
<h2>Conclusion</h2>
<p>I hope you enjoyed this walkthrough of building an animated vertical navigation menu. In implementation, it&#8217;s very similar to the <a href="http://designshack.net/articles/css/downloadbutton/">animated download buttons</a> that we built the other day so you should really be getting the hang of hiding and showing content using pure CSS. </p>
<p>Look out for an even better version of this menu to pop up on our brand new sister site, <a href="http://designcurate.com/">Design Curate</a>. You&#8217;ll find a ton of great freebies there that you can download and implement in your projects today. </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/verticalaccordionav/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<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>Build a Fun Trivia Game With the CSS Active Selector</title>
		<link>http://designshack.net/articles/css/css-active-tutorial/</link>
		<comments>http://designshack.net/articles/css/css-active-tutorial/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 06:00:03 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[:active]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=28424</guid>
		<description><![CDATA[We&#8217;ve done a ton of fun stuff recently with the :hover selector. From button hover effects for beginners to more advanced hover tutorials and even onto using hovers with multiple backgrounds. Today we&#8217;re moving on and learning about a related but equally awesome selector that often gets overlooked. With :active, we can control the state [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-0.jpg" alt="screenshot" width="510"/></div>
<p>We&#8217;ve done a ton of fun stuff recently with the <em>:hover</em> selector. From <a href="http://designshack.net/articles/css/four-simple-and-fun-css-button-hover-effects-for-beginners/">button hover effects for beginners</a> to <a href="http://designshack.net/articles/css/5-cool-css-hover-effects-you-can-copy-and-paste">more advanced hover tutorials</a> and even onto <a href="http://designshack.net/?p=26842">using hovers with multiple backgrounds</a>. Today we&#8217;re moving on and learning about a related but equally awesome selector that often gets overlooked.</p>
<p>With <em>:active</em>, we can control the state of an object while it&#8217;s being clicked. Typically, this takes the simple form of changing a link&#8217;s color while the mouse is pressed down, but we&#8217;re going to do something much more interesting. Follow along as we build a super cool, pure CSS presidential trivia game. </p>
<p><span id="more-28424"></span><br />
<em>Like the article? Be sure to subscribe to our <a href="feed://feeds.feedburner.com/designshack">RSS feed</a> and follow us on <a href="http://twitter.com/designshack">Twitter</a> to stay up on recent content.</em></p>
<h2>What We&#8217;re Building</h2>
<p>The basic idea here is pretty simple. We have a grid of eight pictures with the goal of identifying the men depicted, each of which is a former U.S. president. Hovering over an image slides it down a bit to reveal further instruction, which encourages you to click. Clicking and holding will slide the image down further to reveal the name of the president shown. </p>
<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/presidents/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-2.jpg" alt="screenshot" width="510"/></a></div>
<p><strong>Demo:</strong> <a href="http://designshack.net/tutorialexamples/presidents/index.html">Click here</a> to launch the live version<br />
<strong>Download:</strong> <a href="http://designshack.net/tutorialexamples/presidents/DesignShack-ActiveTut.zip">Click here</a> to download the source files</p>
<h2>Pseudo-class Selectors</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-1.jpg" alt="screenshot" width="510"/></div>
<p>A pseudo-class selector is something that we can use in CSS to modify a basic selector. If this sounds too technical for your liking, don&#8217;t worry, you already use these without even knowing it! The one that you&#8217;re likely to be most familiar with is the <em>:hover</em> pseudo-class selector, which allows you to change the appearance of something on hover. You might also be familiar with fancier pseudo-class selectors such as <em>:first-child</em>.</p>
<p>Regarding links or anchors, there are four of these pseudo-class selectors that you should be familiar with. Here they are with explanations for their use: </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: #3333ff;">:link </span><span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*non-clicked links*/</span>
<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*currently in a mouse-over state*/</span>
<span style="color: #3333ff;">:active </span><span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*currently being clicked*/</span>
<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/*clicked links*/</span></pre></div></div>

</div>
<p></ br></p>
<p>As you can see, our often used hover selector is part of a nice little family that can govern the style of a link at pretty much every state of its existence. It&#8217;s important to note though that this would be a much more interesting set of tools if <em>:visited</em> weren&#8217;t so problematic. Due to security hassles, browsers actually limit what you can do with this pseudo-class. For instance, you can use it change the color of a link, but you can&#8217;t manipulate that link&#8217;s background image. </p>
<p>For this reason, we turn to <em>:active</em> if we want to do anything really fun with a pure CSS click event. It&#8217;s not intuitive to click and hold though so you should tread carefully when using this functionality and always be sure to clearly instruct the user. </p>
<p>Enough of the boring stuff, let&#8217;s get started on our project!</p>
<h2>The HTML</h2>
<p>The HTML for our project is pretty simple. We start off with a brief introduction that states what the game is and how to play it. Here we ask a simple question: &#8220;Who Were the First Eight U.S. Presidents?&#8221; Notice that all of this is thrown into a simple container div. </p>
<p>Next, we create a reusable module to hold our image, which serves as a sort of visual question, and the answer, a simple paragraph that hides below the image. The concept of being reusable is key here. We want to repeat this for seven other presidents and we obviously don&#8217;t want to go through the pain of styling each module individually. For this reason, we apply a class (president), which we can style once and have those styles affect everything that the class is applied to. </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;container&quot;</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Who Were the First Eight U.S. Presidents?<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>Click and hold a picture below to see the <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">em</span>&gt;</span>:active<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">em</span>&gt;</span> selector in action.<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;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;president&quot;</span>&gt;</span>
    	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> George Washington <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1789–1797)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres1.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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>There are a few things to note about the structure of the president div. First, I&#8217;ve got a little bit of voodoo going on with the paragraph. First of all, I&#8217;ve broken the information up into three sections: instruction, name and presidential term. Each piece is put on its own line via a <a href="http://www.w3schools.com/html5/tag_br.asp">break tag</a>. The initial line uses a <em>small</em> tag, which will serve as an easy way to add a bit of visual differentiation to our text so it&#8217;s not monotonous. </p>
<p>Next up is the image, which is wrapped in an anchor tag. Notice though that I don&#8217;t have a link. This is because our anchor doesn&#8217;t serve as a gateway to another page but simply a clickable object. One important side effect here is that anchors don&#8217;t activate a special hover cursor without an &#8220;href&#8221;, which means we&#8217;ll have to do this manually. </p>
<h3>All Eight Presidents</h3>
<p>Now that we&#8217;ve got our basic HTML structure in place, copy and paste the president div until you have eight of them. Then enter the appropriate information for the other presidents. </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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> George Washington <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1789–1797)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres1.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> John Adams <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1797–1801)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres2.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> Thomas Jefferson <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1801–1809)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres3.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> James Madison <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1809–1817)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres4.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> James Monroe <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1817–1825)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres5.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> John Quincy Adams <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1825–1829)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres6.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> Andrew Jackson <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1829–1837)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres7.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>
&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;president&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">small</span>&gt;</span>Click for the answer:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">small</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span> Martin Van Buren <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>(1837–1841)<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;">a</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pres8.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&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>Progress Check</h3>
<p>At this point, we have pretty much all of the HTML that we&#8217;re going to need. However, since we haven&#8217;t styled anything, your live preview should still look pretty rough. You can see everything starting to take shape though, specifically notice that our <em>small</em> tags are already working perfectly. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-3.jpg" alt="screenshot" width="510"/></div>
<h2>Starter CSS</h2>
<p>Now it&#8217;s time to add some style to our quiz. We&#8217;ll start by defining the easy stuff: the container dimensions and instructional typography. We&#8217;ll toss on a generic container size of 960px and add in a margin of &#8220;20px auto&#8221; to center the div horizontally and bring it down from the top a little.</p>
<p>We also need to make the h1 and p tags look good so we toss in some basic font styling. I got a little fancy here and used the CSS child selector (.container > p) to target only paragraphs that are direct descendants of the container. This will ignore the paragraph tags nestled into our president divs. </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;">.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;">960px</span><span style="color: #00AA00;">;</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: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</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</span><span style="color: #00AA00;">:</span> <span style="color: #933;">37px</span>/<span style="color: #cc66cc;">1.5</span> Georgia<span style="color: #00AA00;">,</span> Times<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</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: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&gt;</span> p <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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">13px</span>/<span style="color: #cc66cc;">1.5</span> Verdana<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Progress Check</h3>
<p>Now you should have some nice margins that move the content away from the edge and a pretty headline that no longer uses the default typographic styling. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-4.jpg" alt="screenshot" width="510"/></div>
<h2>Style the President Class</h2>
<p>Now we&#8217;re going to start adding some style to the president class, which should make a huge difference in our layout. To start, we want to float them all to the left and set their dimensions. Since we&#8217;ll be sliding the images in and out, we set the overflow to hidden so nothing breaks out of our little 200px by 200px box. </p>
<p>Next we set the margin to 20px, this is not an arbitrary number. It&#8217;s the carefully calculated value that allows four images per row in our layout. Our width is 960px, which is divided up between four 200px wide images, but 4*200 equals 800, leaving 160 pixels left for margins. 160px/4 images is 40px of margin per image, 20 on the left and 20 on the 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;">.president</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>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
	<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;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</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;">none</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*IE*/</span>
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</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> .2<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</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>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*CSS3 Fancy Inset Shadow*/</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</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> .3<span style="color: #00AA00;">&#41;</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: #cc66cc;">0</span> <span style="color: #933;">20px</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> .3<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</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> .3<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>There are some other points of interest here as well. We&#8217;ll be adding some z-index voodoo later, which actually makes any background color cover up our answer text. To account for this, I used an RGBa background fill at 20%. Older versions of IE don&#8217;t like this so they simply get no background fill. </p>
<p>I also set the cursor to &#8220;pointer&#8221; which will make the little hand appear when we hover over a president. Finally, I added an inset shadow just to make our background look a little nicer. This part is completely optional. </p>
<h3>Progress Check</h3>
<p>At this point things are looking a little weird, but we&#8217;re on the right path. Our president images are being contained and clipped, which is good, but the background text is actually pushing them down, which we don&#8217;t want. Instead we want the image to float over the text. We&#8217;ll accomplish this in the next step.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-5.jpg" alt="screenshot" width="510"/></div>
<h2>Fix the Text Styles and Stacking Order</h2>
<p>Before we proceed to making all of this work, let&#8217;s style our paragraph text real quick. If we wait any longer it will be hidden behind the images and harder to keep an eye on.</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;">.president</span> p <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">13px</span>/<span style="color: #cc66cc;">1.5</span> Verdana<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">190px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.president</span> p small <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span>/<span style="color: #cc66cc;">1.5</span> Verdana<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>These styles should make all our text look much better. Notice that even though the small tag has default styling, it can and should be easily overridden in a manual fashion. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-6.jpg" alt="screenshot" width="510"/></div>
<h3>Putting the Text Behind the Images</h3>
<p>As I mentioned above, we don&#8217;t want our paragraphs to push down the image but instead hide behind it. To accomplish this we set it free from the flow from with absolute positioning and then move it behind the image with a z-index of -1. </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;">.president</span> p <span style="color: #00AA00;">&#123;</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>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">190px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">13px</span>/<span style="color: #cc66cc;">1.5</span> Verdana<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.president</span> p small <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span>/<span style="color: #cc66cc;">1.5</span> Verdana<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This gets everything right where we want it. The text is hiding behind the image and each image is finally being shown in its full form. The problem? There&#8217;s no way to see the answer!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-7.jpg" alt="screenshot" width="510"/></div>
<h2>Bring It to Life</h2>
<p>Now that we&#8217;ve got everything right where we want it, it&#8217;s time to add the interaction. Let&#8217;s think about how we want it to work: We&#8217;ve already got the default state coded so we&#8217;re good there. The next step is the hover event. This should bump down the image, but only a little, just enough to show the first line of text. Then on the click, we want to bring the image down even further. </p>
<p>This all needs to happen with some nice transitions of course so it turns out that our first step is to set these up on the images. As always, we need a million different versions to account for all of the various browsers:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a img <span style="color: #00AA00;">&#123;</span>
	-webkit-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">margin</span> 0.3s ease<span style="color: #00AA00;">;</span>
	-moz-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">margin</span> 0.3s ease<span style="color: #00AA00;">;</span>
	-o-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">margin</span> 0.3s ease<span style="color: #00AA00;">;</span>
	-ms-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">margin</span> 0.3s ease<span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">margin</span> 0.3s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>With these transitions in place, any time we change the margins on our images, the transition will be animated. So our next step is to define the hover event with our favorite pseudo-class selector. </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: #3333ff;">:hover </span>img <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This adds a little bit of margin to the top of our image so that when the user hovers over it, this is what they&#8217;ll see:</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-8.jpg" alt="screenshot" width="510"/></div>
<p>This serves as a nice little tip for how to get the answer. If we showed the full answer here, we would likely have an issue with accidental reveals, the click serves as a more concrete way to ensure intentionality. </p>
<p>Our final piece of CSS is what we came here to learn about: the active pseudo class selector. By implementing this small but powerful final piece, our entire trivia game comes together.</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: #3333ff;">:active </span>img <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Now when a user clicks on an image and holds the button down, the image of the president slides down and his name is revealed. With that, we&#8217;re all finished!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/activetut-9.jpg" alt="screenshot" width="510"/></div>
<h2>Conclusion</h2>
<p>After reading through this tutorial you should know a ton of great stuff about some of the most popular pseudo class selectors and how to use them to come up with some really interesting results. We combined the hover and active selectors to create a pure CSS trivia game where the user first hovers and then clicks to see a hidden message. </p>
<p>Leave a comment below and let us know if you learned anything. Also be sure to check out the <a href="http://designshack.net/tutorialexamples/presidents/index.html">live demo</a>. Can you name all eight presidents successfully?</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/css-active-tutorial/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mastering Mouse Enter and Exit Events With CSS Transitions</title>
		<link>http://designshack.net/articles/css/mastering-mouse-enter-and-exit-events-with-css-transitions/</link>
		<comments>http://designshack.net/articles/css/mastering-mouse-enter-and-exit-events-with-css-transitions/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 06:00:43 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[mousein]]></category>
		<category><![CDATA[mouseout]]></category>
		<category><![CDATA[transitions]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=28025</guid>
		<description><![CDATA[While working on a recent post that utilized CSS transitions, I stumbled upon some interesting revelations completely by accident. Switching up where you place the transition syntax can have a dramatic effect on how the transition is carried out. Today we&#8217;re going to go over the various options for CSS transition syntax and how each [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/mouseinout-5.jpg" alt="screenshot" width="510"/></div>
<p>While working on a recent post that utilized CSS transitions, I stumbled upon some interesting revelations completely by accident. Switching up where you place the transition syntax can have a dramatic effect on how the transition is carried out. </p>
<p>Today we&#8217;re going to go over the various options for CSS transition syntax and how each affects the animation given whether your mouse is entering or exiting a hover. </p>
<p><span id="more-28025"></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>Mouse Events in CSS</h2>
<p>CSS transitions give us the awesome ability to implement simple animations without JavaScript. However, since there&#8217;s really not much talk about it in CSS, you would think that differing your mouse over and mouse out effects would still be something squarely in the realm of JavaScript. After all, there&#8217;s no support for 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;">div <span style="color: #00AA00;">&#123;</span>
	mouseover-transition<span style="color: #00AA00;">:</span> all 2s ease<span style="color: #00AA00;">;</span>
	mouseout-transition<span style="color: #00AA00;">:</span> all 1s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>However, it turns out you can in fact effectively control these two different variables. It&#8217;s simply not a very intuitive process. Let&#8217;s take a look at how it works.</p>
<p><em>If you want to skip the discussion and go straight to the syntax, <a href="http://css-tricks.com/different-transitions-for-hover-on-hover-off/">CSS Tricks</a> has a good example of this technique.</em></p>
<h2>The Normal Syntax: Mouse In and Out Are Equal</h2>
<div class="tutorialimage"><a href="http://dabblet.com/gist/1535314"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/mouseinout-1.jpg" alt="screenshot" width="510"/></a></div>
<p>There are a few different ways that we can go about applying a CSS transition. The first one we&#8217;ll look at is the plain old default, meaning we&#8217;ll use the standard syntax that you&#8217;ll find if you run a Google search for how to implement a CSS transition.</p>
<p>For experimentation purposes, we&#8217;ll keep the demo simple. We want the transition to animate the shift from a black square to a gray circle. Here&#8217;s how this looks (browser prefixes omitted for cleanliness):</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;">#loremdiv</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;">200px</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: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 1s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#loremdiv</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>1080deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The behavior of this animation is typical. When you hover over the black square, in the course of one second it spins around as it increases its border radius to 100px and changes its color, making it a gray circle. Then when you take your mouse out, the opposite happens. The square spins counter clockwise back to its original position has its border radius steadily decreases and its color goes back to black. </p>
<p><strong>Demo:</strong> <a href="http://dabblet.com/gist/1535314">Click here</a> to see this example in action.</p>
<h2>Reversed Syntax: No Mouse Out Transition</h2>
<div class="tutorialimage"><a href="http://dabblet.com/gist/1535412"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/mouseinout-2.jpg" alt="screenshot" width="510"/></a></div>
<p>In the previous example, we placed the transition syntax in the <em>#loremdiv</em> selector. What happens if we reverse this and place the same snippet inside of the <em>#loremdiv: hover</em> selector? </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;">#loremdiv</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;">200px</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: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#loremdiv</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>1080deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 1s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Even though it feels wrong, it turns out that this still produces a transition. However, it <strong>only</strong> produces a transition on the hover event, when the user exits the hover, the transformation is immediate.</p>
<p>This effectively gives us what we were looking for: a way to vary the mouse in and mouse out transitions. However, the mouse out is really no transition at all at this point, which isn&#8217;t very exciting.  </p>
<p><strong>Demo:</strong> <a href="http://dabblet.com/gist/1535412">Click here</a> to see this example in action.</p>
<h2>Doubled Syntax: Two Customizable Transitions</h2>
<div class="tutorialimage"><a href="http://dabblet.com/gist/1535470"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/mouseinout-3.jpg" alt="screenshot" width="510"/></a></div>
<p>Now we&#8217;ve tried linking the transition to the normal selector and we&#8217;ve tried putting it in the hover selector, now let&#8217;s see what happens when we put a transition in <strong>both</strong> places. </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;">#loremdiv</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;">200px</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: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 0.3s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#loremdiv</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>1080deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 1s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Notice that I&#8217;ve reduced the amount of time on the first transition so that we can tell what it does. Interestingly enough, the result here is the opposite of what many people expect. </p>
<p>Intuitively, you might come to the conclusion that the first transition statement will be applied on mouse in and the second on mouse out. However, the opposite is true. As we discovered in our last example, the snippet associated with the hover selector affects the mouse in event, leaving the other one for the mouse out. </p>
<p>Now we have the setup that we were shooting for! This gives us complete freedom to vary the mouse in and mouse out effects. What I&#8217;ve done with this example is reduce the amount of time that it takes for the animation to complete when the user exits the hover. </p>
<p><strong>Demo:</strong> <a href="http://dabblet.com/gist/1535470">Click here</a> to see this example in action.</p>
<h2>Varying the Effects</h2>
<div class="tutorialimage"><a href="http://dabblet.com/gist/1535530"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/mouseinout-4.jpg" alt="screenshot" width="510"/></a></div>
<p>Taking this idea even further, you can&#8217;t only vary the time, you can also vary the property and timing function. Here&#8217;s an example:</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;">#loremdiv</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;">200px</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: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> border-radius 0.5s ease-in<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#loremdiv</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>1080deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 1s ease<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Here I stuck with the same animation that we&#8217;ve been using for the hover event, but when the user exits the hover, the only thing that animates back is the border radius. </p>
<p><strong>Demo:</strong> <a href="http://dabblet.com/gist/1535530">Click here</a> to see this example in action.</p>
<h2>Conclusion</h2>
<p>To sum up, there are three basic ways that you can approach CSS transitions. The first way is to link the transition to a non-hover selector. This makes the hover in and out transitions the same (only in reverse of course). The second way is to link the transition to a hover selector. This creates a hover in transition but eliminates the hover out transition.</p>
<p>Finally, the third way is to link transitions to both selectors. In this case, the non-hover transition will affect the <strong>hover out</strong> event and the hover transition will effect the <strong>hover in</strong> event. This is the technique that you&#8217;ll want to go with if you want the most control over 	the separate events.</p>
<p>Leave a comment below and let us know what you think of all this. Have you ever noticed that separate hover in/out events were possible? Have you utilized this in any way? </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/mastering-mouse-enter-and-exit-events-with-css-transitions/feed/</wfw:commentRss>
		<slash:comments>3</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>6 Things I Learned About Print Stylesheets From HTML5 Boilerplate</title>
		<link>http://designshack.net/articles/css/6-thinks-i-learned-about-print-stylesheets-from-html5-boilerplate/</link>
		<comments>http://designshack.net/articles/css/6-thinks-i-learned-about-print-stylesheets-from-html5-boilerplate/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 17:41:52 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[stylesheets]]></category>

		<guid isPermaLink="false">http://designshack.net/?p=26484</guid>
		<description><![CDATA[Print stylesheets can be a pain if you don&#8217;t know what you&#8217;re doing. Before you even approach one you need to make sure to do some solid research into how to go about it. Today we&#8217;re going to help you along by first discussing the conceptual considerations that you need to keep in mind when [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/printcss-2.jpg" alt="screenshot" width="510"/></div>
<p>Print stylesheets can be a pain if you don&#8217;t know what you&#8217;re doing. Before you even approach one you need to make sure to do some solid research into how to go about it.</p>
<p>Today we&#8217;re going to help you along by first discussing the conceptual considerations that you need to keep in mind when creating a print stylesheet. Then we&#8217;ll dive into some code from the famous <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a> to see some modern solutions for addressing the problems that arise when printing from the web. </p>
<p><span id="more-26484"></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>Where Web Design Meets Print</h2>
<p>The web and print are two fundamentally different beasts. They&#8217;re so different that you&#8217;ll often find designers who work full time in one medium or the other with almost no cross over. As a result, print designers often know very little about web design and web designers know very little about print design.</p>
<p>However, interestingly enough, most experts call for a little bit of overlap in every single web project you create. We&#8217;re of course talking about print stylesheets, which result in a sort of bizarro world where CSS is being used to design for print! It&#8217;s a crazy scenario, but you&#8217;re expected to plan for it nevertheless. </p>
<p>Unfortunately, even if you know your way around CSS fairly well, print stylesheets can throw you some curveballs. There are quite a few quirky tricks that you&#8217;ll need to implement in addition to plenty of conceptual planning.</p>
<p>Let&#8217;s see how to start this process by asking a few key questions.</p>
<h2>Print vs. Web: What Are the Fundamental Differences?</h2>
<p>This is an important question to ask yourself when creating a print stylesheet. After all, you&#8217;re converting a design from one medium to another so it pays to give some thought to how they differ.</p>
<div class="pullquote-r">
&#8220;You’re converting a design from one medium to another so it pays to give some thought to how they differ&#8221;
</div>
<p></ br></p>
<p>Let&#8217;s think about the obvious areas. First of all, a page is a very limited canvas. Websites represent a fairly infinite space that can scroll as far as you want in any direction. Physical pages however, are stuck at 8.5&#8243; by 11&#8243; with a printable area of even less than that.</p>
<p>This has major implications. It means that lengthy content will eat up tons of paper. This leads us to think about where we can cut back. For instance, if we&#8217;re printing articles with hundreds of comments, maybe we should turn those off. There&#8217;s also an obvious change that must be made to the width of our content. Both the copy and the images need to be sized appropriately.</p>
<h3>Interaction</h3>
<p>Another major difference between print and the web is the capacity for interaction. The web represents a richly interactive dynamic medium while print is static; what&#8217;s on the paper is stuck there! </p>
<p>This means you need to rethink any interactive elements on the page. For instance, navigation menus are usually one of the first things to go. A printed page has no use for them and they can really eat up space if converted to simple unordered lists. </p>
<div class="pullquote-r">
&#8220;You need a good way to take all those inline links and show the reader where they lead&#8221;
</div>
<p></ br></p>
<p>You also have to consider what&#8217;s going to happen with image sliders and the like. If your page has a slideshow with ten images at the top, that&#8217;s not going to translate well to paper. </p>
<p>The most basic level of interaction on the web is a link. This too becomes problematic. On your computer, you can simply click a link to see where it goes, on paper this functionality is lost so you need a good way to take all those inline links and show the reader where they lead. </p>
<h2>Who is Printing this Page and Why?</h2>
<p>The second important question that needs to be asked relates to why the page is being printed in the first place. A good designer doesn&#8217;t just set out to make things look good, the design has to maximize utility for the user.</p>
<div class="pullquote-r">
&#8220;A good designer doesn&#8217;t just set out to make things look good, the design has to maximize utility for the user.&#8221;
</div>
<p></ br></p>
<p>This of course means that you have to consider just what the typical user wants. This isn&#8217;t going to be a universal answer. Every type of project will have a unique use for the printed page.</p>
<p>For instance, Google Maps users want just about everything stripped off the page for print: ads, the huge interactive map, the Google search bar, all of this and more must be ditched for a clean list of readable directions. </p>
<p>These goals are obviously quite different from someone who prints out a design blog post to circulate around at a meeting as a discussion point. Here the emphasis is on presentation of lots of text rather than very little. </p>
<h2>Learning By Example: HTML5 Boilerplate</h2>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.co.uk/wp-content/uploads/printcss-1.jpg" alt="screenshot" width="510"/></div>
<p>When you&#8217;re working with types of CSS that you&#8217;ve never approached before, one of the best possible ways to learn is to simply look around and see what others are doing.</p>
<p>The first place I usually start in cases like this is Paul Irish&#8217;s <a href="http://html5boilerplate.com/">HTML5 Boilterplate</a>. This project is a rock solid collaboration from leading industry professionals. It&#8217;s not by any means infallible but it&#8217;s still a great example to learn from. </p>
<p>If we download the Boilerplate and crack open the CSS file, we find the print styles at the very bottom:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media print {</span>
  <span style="color: #00AA00;">*</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> !important<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">black</span> !important<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span> filter<span style="color: #00AA00;">:</span><span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span> -ms-filter<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* Black prints faster: h5bp.com/s */</span>
  a<span style="color: #00AA00;">,</span> a<span style="color: #3333ff;">:visited </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>
  a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">&#93;</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> attr<span style="color: #00AA00;">&#40;</span>href<span style="color: #00AA00;">&#41;</span> <span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  abbr<span style="color: #00AA00;">&#91;</span>title<span style="color: #00AA00;">&#93;</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> attr<span style="color: #00AA00;">&#40;</span>title<span style="color: #00AA00;">&#41;</span> <span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.ir</span> a<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span> a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">&quot;javascript:&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span> a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #00AA00;">&#93;</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: #00AA00;">&#125;</span>  <span style="color: #808080; font-style: italic;">/* Don't show links for images, or javascript/internal links */</span>
  pre<span style="color: #00AA00;">,</span> blockquote <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">page-break-inside</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">avoid</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  thead <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">table-header-group</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* h5bp.com/t */</span>
  tr<span style="color: #00AA00;">,</span> img <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">page-break-inside</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">avoid</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  img <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;">100%</span> !important<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  <span style="color: #a1a100;">@page { margin: 0.5cm; }</span>
  p<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">orphans</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">widows</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">3</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  h2<span style="color: #00AA00;">,</span> h3 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">page-break-after</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">avoid</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>This fairly small chunk of code has a lot going on, which means there&#8217;s plenty to learn from. Let&#8217;s dive in and see what we can find.</p>
<h3>Print Media Query</h3>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media print {}</span></pre></div></div>

</div>
<p></ br></p>
<p>The very first thing you should notice is the use of a media query to specify the print styles. This tells the browser that all the styles contained in this block are only to be applied under a special circumstance, in this case a user printing the page (this will help end the old &#8220;click for printer friendly version&#8221; technique). </p>
<h3>Universal Selector and Blanket Styles</h3>
<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;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span> !important<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">black</span> !important<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span> filter<span style="color: #00AA00;">:</span><span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span> -ms-filter<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span> !important<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The next thing I notice is that the universal selector (*) is immediately whipped out to apply some blanket style changes to the page. </p>
<p>The result here is a drastic simplification of the visual styles on the page. Any background image or color is turned off, the text color is turned to black, text-shadows are disabled, etc. All of this both improves readability and saves on ink.</p>
<h3>Print Friendly Links</h3>
<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;">,</span> a<span style="color: #3333ff;">:visited </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>
  a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">&#93;</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> attr<span style="color: #00AA00;">&#40;</span>href<span style="color: #00AA00;">&#41;</span> <span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  abbr<span style="color: #00AA00;">&#91;</span>title<span style="color: #00AA00;">&#93;</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> attr<span style="color: #00AA00;">&#40;</span>title<span style="color: #00AA00;">&#41;</span> <span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.ir</span> a<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span> a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">&quot;javascript:&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span> a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #00AA00;">&#93;</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: #00AA00;">&#125;</span>  <span style="color: #808080; font-style: italic;">/* Don't show links for images, or javascript/internal links */</span></pre></div></div>

</div>
<p></ br></p>
<p>Remember we said above that something would have to be done about printed links? It turns out that you can handle this task using pure CSS, an impressive feat! Good old Eric Meyer was doing this way back in 2002 on A List Apart&#8217;s <a href="http://www.alistapart.com/articles/goingtoprint/">CSS Design: Going to Print</a>.</p>
<p>After first applying an underline to all the links on the page to help them stand out (some slightly change the color as well), there&#8217;s a snippet of code applied that actually prints out the link after the text:</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;">&#93;</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> attr<span style="color: #00AA00;">&#40;</span>href<span style="color: #00AA00;">&#41;</span> <span style="color: #ff0000;">&quot;)&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The result is that a typical <a href="http://goo.gl/CWGL4">link</a> will be changed to <u>link (http://goo.gl/CWGL4)</u>. As you can see, this is perfect for a printout. As a side note, not all browsers will support the CSS above, but those that won&#8217;t will print just fine, only without the parenthetical link text thrown in. </p>
<p>Notice that the Boilerplate goes one step further by disabling this action on images and JavaScript containing links. </p>
<h3>Optimizing Page Breaks</h3>
<p>You&#8217;ll notice plenty of code for dealing with page breaks: <em>page-break-after: avoid;</em> and <em>p, h2, h3 { orphans: 3; widows: 3; }</em> are both aimed at helping the pages flow better. The former forbids a page break directly after headers and paragraphs where possible, the latter ensures that no less than three lines can be orphaned or widowed on a page.</p>
<p>What are orphans and widows? When you have the first line of a paragraph stranded alone at the bottom of a page, that&#8217;s an orphan. Similarly, the last line of a paragraph may be carried over by itself to the next page, this is a widow. The code above ensures that, where possible, at least three lines of text will appear.  </p>
<h3>Image Sizing</h3>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">img <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;">100%</span> !important<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Setting the image maximum width to 100% ensures that you don&#8217;t have any weird bleeding images. You&#8217;ve probably run into this before as a user: you go to print a web page and end up with several pages containing only partial images that were cutoff from the main page. This is easily preventable with the single line of code above!</p>
<h3>Page Margins</h3>
<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;">@page { margin: 0.5cm; }</span></pre></div></div>

</div>
<p></ br></p>
<p>The way that the HTML5 Boilerplate defines page margins is very interesting. Most older articles about print stylesheets include very different methods. In fact, I didn&#8217;t even know about this method until writing this article.</p>
<p>It turns out that you can use <a href="http://www.w3.org/TR/CSS21/page.html#page-box">@page</a> to simply apply a margin all the way around the page. The code above applies a margin of 0.5cm (centimeters is CSS? Oh my!) to all pages uniformly.</p>
<p>If you want to get tricky, you can modify this to adjust the settings for every other page. The following code sets the left page (1, 3, 5, etc.) and right page (2, 4, 6, etc.) margins independently. </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;">@page :left{ margin: 0.5cm; }</span>
<span style="color: #a1a100;">@page :right{ margin: 0.8cm; }</span></pre></div></div>

</div>
<p></ br></p>
<p>It&#8217;s a simple and elegant solution that is, surprisingly enough, CSS2. </p>
<h2>Further Reading</h2>
<p>Since HTML5 Boilerplate is a generic template, it doesn&#8217;t contain many of the code snippets that are typical of very specific types of sites like blogs. Before attacking your own print stylesheet project, browse a few of the following articles to make sure you&#8217;re up to speed.</p>
<ul>
<li><a href="http://www.webdesignerdepot.com/2010/01/10-tips-for-better-print-style-sheets/">10 Tips for Better Print Style Sheets</a> from Web Designer Depot</li>
<li><a href="http://alisothegeek.com/2010/01/how-to-make-a-great-print-stylesheet/">How to Make a Great Print Stylesheet</a> from Aliso the Geek </li>
<li><a href="http://meiert.com/en/blog/20070221/print-style-sheets-the-basics-for-no-excuses/">Print Style Sheets: The Basics (for No Excuses)</a>  by Jens Meiert</li>
<li><a href="http://www.webcredible.co.uk/user-friendly-resources/css/print-stylesheet.shtml">Print Stylesheet &#8211; the Definitive Guide</a>  from Webcredible</li>
</ul>
<h2>Conclusion</h2>
<p>Print stylesheets represent a completely different way to think about and use CSS. They&#8217;re not always the most intuitive of tasks so don&#8217;t expect to intuitively land on the right answers. Be sure to do your homework and test extensively.</p>
<p>Do you have any tricks or best practices regarding print stylesheets? Let us know in the comments below!</p>
<p><!-- <em>Author&#8217;s Note: I&#8217;m not personally in charge of Design Shack&#8217;s design, so don&#8217;t yell at me about the CSS of this page. I&#8217;ll put a word in and see if we can get some better print styles. </em> &#8211;></p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/6-thinks-i-learned-about-print-stylesheets-from-html5-boilerplate/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CSS Button Tutorial: How to Code Buttons in 5 Simple Steps</title>
		<link>http://designshack.net/articles/css/css-button-tutorial-how-to-code-buttons-in-5-simple-steps/</link>
		<comments>http://designshack.net/articles/css/css-button-tutorial-how-to-code-buttons-in-5-simple-steps/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 21:00:17 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[button]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=25423</guid>
		<description><![CDATA[Here at Design Shack we like to feature a full range of tutorials, from expert PHP projects to very simple CSS tips. Today&#8217;s tutorial is targeted at those still in the beginner stages of CSS. One of the most frequent questions I get from CSS beginners is, &#8220;How do I create a button?&#8221; It&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>Here at Design Shack we like to feature a full range of tutorials, from expert PHP projects to very simple CSS tips. Today&#8217;s tutorial is targeted at those still in the beginner stages of CSS. </p>
<p>One of the most frequent questions I get from CSS beginners is, &#8220;How do I create a button?&#8221; It&#8217;s a simple question with a complicated answer. There are quite a few ways to go about it and unfortunately there are also quite a few ways to go wrong. When I first started out in CSS, figuring out all the button syntax was one of the most persistent troubles I faced, it seemed like I was always doing it wrong. Today we&#8217;re going to walk through a very simple and flexible process that you can apply to any button you create. More important than the end result is the in-depth explanation at each point outlining why we do it that way. </p>
<p><span id="more-25423"></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>Step 1: The HTML</h2>
<p>Believe it or not, this is one of the trickiest parts. To an experienced coder, it seems so simple. To a beginner though, knowing where to start with a button can be quite difficult. Should you use the &#8220;button&#8221; HTML tag? Or perhaps a paragraph tag? Which parts should the link wrap around?</p>
<p>It turns out that the simplest and most widely used syntax is just to implement a plain old anchor tag (form buttons often use &#8220;input&#8221;). From a functional standpoint, all we&#8217;re really trying to create is a link that, when clicked, takes us somewhere new, which is exactly what a basic HTML link does. Often in web design, the choice to turn something into a button is merely an aesthetic one and doesn&#8217;t necessarily indicate any special functionality. </p>
<p>Here&#8217;s a widely used snippet of HTML that gets the job done perfectly while staying nice and succinct:</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;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://designshack.net/&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span>&gt;</span>Click Me<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

</div>
<p></ br></p>
<h3>If You Don&#8217;t Need a Div, Don&#8217;t Use One</h3>
<p>One problem that I used to come across when I first started coding is that I would often think that I needed a div to create anything. Using this flawed logic, I would wrap my anchor in a div and then apply most of the styling to the div.</p>
<p>This is completely unnecessary though and can create problems with both the click and the hover. In the above example, our entire element will be the link. If we wrapped this in a div and styled that, only the text part of the button would be a link, meaning that the user could conceivably click the button with no result.  </p>
<h3>Why Use a Class?</h3>
<p>Perhaps the most important thing to notice about this snippet of code is that we&#8217;ve added a class, which I&#8217;ve generically labeled &#8220;button.&#8221; There are a couple of reasons for this.</p>
<p>First of all, we need a way to target and style this button in our CSS without necessarily targeting all of the anchor tags on the page. It&#8217;s almost never the case that you&#8217;ll want every single link to be an identical button. However, it is feasible and quite likely that you will in fact want to reuse the button style at some point. For this reason we apply a class instead of an ID. That way, whenever we want to convert a plain text link to a nice button, we simply apply our &#8220;button&#8221; class and we&#8217;re done!</p>
<h3>Step 1 Preview</h3>
<p>At this point you should only have a plain text link with default styling. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssbuttontut-1.png" alt="css button" width="510"/></div>
<h2>Step 2: Basic Button Styles</h2>
<p>Now that we&#8217;ve got our HTML all ready to go, it&#8217;s time to jump over to the CSS. Remember that we set up a &#8220;button&#8221; class for the express purpose of CSS targeting so be sure to use it for this 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: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span><span style="color: #808080; font-style: italic;">/* Code Here */</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The first thing we want to do in our CSS is define the basic box that will make up our button shape. Here are the styles that I used. Note that my color choices and dimensions are completely optional, feel free to use whatever you like.</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: #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;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#34696f</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> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">68</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">72</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.59</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>The most important thing I did here was to set &#8220;display&#8221; to &#8220;block&#8221;. This will allow us to turn our text link into a larger box with a defined width and height. After that I simply set my size and background color, then added a border. I&#8217;ll be using &#8220;rgba&#8221; quite a bit, if you want to make this a little more friendly to older browsers, check out <a href="http://css-tricks.com/2151-rgba-browser-support/">this article</a> on declaring rgba fallbacks.</p>
<h3>Step 2 Preview</h3>
<p>After step two you should have a fairly boring looking box with some impossible to read text inside. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssbuttontut-2.png" alt="css button" width="510"/></div>
<h2>Step 3: Text Styles</h2>
<p>Next up, it&#8217;s time to attack that ugly text. To make sure you can keep up with each step, I&#8217;ll simply keep adding to what we&#8217;ve previously built with comments to help you see each 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: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 2: Basic Button Styles*/</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;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#34696f</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> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">68</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">72</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.59</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 3: Text Styles*/</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</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.55</span><span style="color: #00AA00;">&#41;</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">3.2em</span>/<span style="color: #933;">100px</span> <span style="color: #ff0000;">&quot;Helvetica Neue&quot;</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> Geneva<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: #808080; font-style: italic;">/*Step 3: Link Styling*/</span>
a<span style="color: #6666ff;">.button</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;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Here we see that I&#8217;ve added in a text color that&#8217;s essentially a darker shade of the button color. This trick is accomplished by setting the text color to black and reducing the opacity via rgba. Next, I center aligned the text and declare a bunch of stuff using font shorthand.</p>
<h3>Font Shorthand</h3>
<p>CSS shorthand is a neat way to declare a bunch of CSS properties and styles in one line. First, I declared the weight (bold), then font-size/line-height and finally the font-family. Notice that the line-height is set exactly to the button height. This is a simple way to make sure your text is vertically centered. </p>
<p>For more information on CSS Shorthand, check out <a href="http://designshack.net/articles/css/6-css-shorthand-tricks-every-developer-should-know">6 CSS Shorthand Tricks Every Developer Should Know</a>.</p>
<h3>Step 3 Preview</h3>
<p>After step three your button should actually start to look like a button!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssbuttontut-3.jpg" alt="css button" width="510"/></div>
<h2>Step 4: Fancy CSS3 Styles</h2>
<p>The previous step gets us to a nice, functioning button that doesn&#8217;t look half bad. Unfortunately, it is quite boring. The important part though is that this button should look perfect in most browsers, so we can now proceed to add some newer CSS goodness without worrying too much about leaving older browsers behind. Ultimately, I don&#8217;t really mind if IE decides to ditch these next styles because my button should work just fine for those users in its current state.</p>
<p>We can easily get carried away and write fifty lines of CSS to make our button shining and pretty, but I&#8217;ll keep it really simple for today&#8217;s purposes:</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: #00AA00;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 2: Basic Button Styles*/</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;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#34696f</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> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">68</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">72</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.59</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 3: Text Styles*/</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</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.55</span><span style="color: #00AA00;">&#41;</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">3.2em</span>/<span style="color: #933;">100px</span> <span style="color: #ff0000;">&quot;Helvetica Neue&quot;</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 4: Fancy CSS3 Styles*/</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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</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;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Step 3: Link Styling*/</span>
a<span style="color: #6666ff;">.button</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;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Each of these can be tricky to read so let&#8217;s go through them one by one. First, I added a gradient that uses the color we already had in place and fades to something a tiny by darker. I left in my previous background color above that section to act as a fallback.</p>
<p>Next up is the border radius. I decided to go with a really heavy rounded corner that will give the button a pill shape. Since I want all my corners to be the same, I simply declare one value and it gets applied uniformly.</p>
<p>Finally, I threw in some shadows. Both the box and the text shadow that I used are a little peculiar. For the box shadow, a gave it a vertical offset but no horizontal one and also left the feathering at 0. This will give a nice little faux 3D effect that doesn&#8217;t require too much work or code. For the text shadow, I also applied a vertical offset and set the color to white at 20% opacity. This is a super easy way to create a letterpressed effect and make the text appear as if it sinks into the button. </p>
<h3>Use <a href="http://prefixr.com/index.php">Prefixr</a> for Browser Prefixes</h3>
<p>Notice that the code above isn&#8217;t cross-browser compatible at all. In the initial stages of experimentation, I hate mucking up my code with half a dozen browser prefixes and often forget whether or not a given browser has a unique syntax. </p>
<p>Once I&#8217;ve got things looking the way I want in Espresso (my IDE of choice) using basic syntax, I can toss all of that code into a little free tool called <a href="http://prefixr.com/">Prefixr</a>, which will process it and spit out my code with all of the correct available browser specific versions automatically added.</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: #00AA00;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 2: Basic Button Styles*/</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;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#34696f</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> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">68</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">72</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.59</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 3: Text Styles*/</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</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.55</span><span style="color: #00AA00;">&#41;</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">3.2em</span>/<span style="color: #933;">100px</span> <span style="color: #ff0000;">&quot;Helvetica Neue&quot;</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 4: Fancy CSS3 Styles*/</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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> 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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	-khtml-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
&nbsp;
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</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;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Step 3: Link Styling*/</span>
a<span style="color: #6666ff;">.button</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;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Step 4 Preview</h3>
<p>After step four, your button should look much sharper than before. Almost finished!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssbuttontut-4.jpg" alt="css button" width="510"/></div>
<h2>Step 5: Hover Styles</h2>
<p>The final step in our button process is to define the hover behavior. When the user hovers over the button, it&#8217;s always nice to get a little visual feedback that&#8217;s more than the default cursor change. Once again, we could go all out with this but I&#8217;ll keep it simple and just lighten up the gradient a little:</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: #00AA00;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 2: Basic Button Styles*/</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;">100px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#34696f</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> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">68</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">72</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.59</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 3: Text Styles*/</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</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.55</span><span style="color: #00AA00;">&#41;</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;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">3.2em</span>/<span style="color: #933;">100px</span> <span style="color: #ff0000;">&quot;Helvetica Neue&quot;</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> Geneva<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/*Step 4: Fancy CSS3 Styles*/</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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> 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;">#34696f</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
&nbsp;
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	-khtml-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
&nbsp;
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#1b383b</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</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;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Step 3: Link Styles*/</span>
a<span style="color: #6666ff;">.button2</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;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*Step 5: Hover Styles*/</span>
a<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#3d7a80</span><span style="color: #00AA00;">;</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;">#3d7a80</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#3d7a80</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -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;">#3d7a80</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -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;">#3d7a80</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> 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;">#3d7a80</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#2f5f63</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 when you hover over the button, its color/brightness will shift. It&#8217;s a subtle effect but is definitely strong enough for any user to notice, even if they&#8217;re colorblind. </p>
<h2>Finished!</h2>
<p>After step five, you&#8217;re all done! You should now have a beautiful button created entirely with CSS and HTML. More importantly though, you should have a strong feel for the basic workflow to follow to craft a button using CSS.</p>
<div class="tutorialimage"><a href="http://designshack.net/tutorialexamples/cssbutton/button.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssbuttontut-5.jpg" alt="css button" width="510"/></a></div>
<p><strong>Demo:</strong> To see the button in action, <a href="http://designshack.net/tutorialexamples/cssbutton/button.html">click here</a> or on the image above.<br />
<strong>jsFiddle:</strong> To Fiddle with the code, <a href="http://jsfiddle.net/secondfre/mtUpA/">click here</a>.</p>
<h2>Conclusion</h2>
<p>We learned a lot of very important things today. First, we saw that we can use a basic HTML anchor tag as the starting point for our button and that it&#8217;s good to style buttons with reusable classes. We also learned how to start by styling a basic button that will work well across all browsers and to toss in added flair later rather than basing the entire structure of the button on techniques that won&#8217;t be be widely accessible. Finally, we saw how to keep things simple by coding with basic CSS3 properties until we get everything just right, and then follow that up with a trip to <a href="http://prefixr.com/">Prefixr</a>, which expands our code to something as cross-browser compatible as possible. </p>
<p>Leave a comment below and let us know what you think. If you&#8217;re a beginner, was this helpful to you? If you&#8217;re a seasoned pro, what would you do differently?</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/css-button-tutorial-how-to-code-buttons-in-5-simple-steps/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The Ultimate Collection of 50+ Resources for Grid Lovers</title>
		<link>http://designshack.net/articles/layouts/the-ultimate-collection-of-50-resources-for-grid-lovers/</link>
		<comments>http://designshack.net/articles/layouts/the-ultimate-collection-of-50-resources-for-grid-lovers/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 18:00:14 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[Layouts]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[grid]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=23419</guid>
		<description><![CDATA[If you love grid-based design, this article is for you. We&#8217;ve scoured the web and compiled every great grid resource we could find. We&#8217;ve got all the best frameworks, grid builders, how-to guides and more. Commence browsing and bookmarking! Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter [...]]]></description>
			<content:encoded><![CDATA[<p>If you love grid-based design, this article is for you. We&#8217;ve scoured the web and compiled every great grid resource we could find. We&#8217;ve got all the best frameworks, grid builders, how-to guides and more.</p>
<p>Commence browsing and bookmarking!</p>
<p><span id="more-23419"></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>Hate Grid Frameworks?</h2>
<p>Before we get started, I just want to say that I know full well that many of the people reading this are already bursting with anger about the evils of layout frameworks.</p>
<p>In truth, there&#8217;s a lot to be said against grid frameworks. They&#8217;re cumbersome, have a learning curve and often toss semantics out the window. Further, there are a million of these things, which makes it hard for discussions of standard practices to even begin. </p>
<p>If you fall into the camp of CSS framework haters, don&#8217;t worry there are still plenty of grid design resources below that have nothing to do with frameworks. In the mean time, here are a few alternatives to grid frameworks.</p>
<h3><a href="http://designshack.net/articles/css/rolling-your-own-grid-layouts-on-the-fly-without-a-framework/">Rolling Your Own Grid Layouts On the Fly</a></h3>
<p>I recently published a piece on how to easily achieve complex multi-column layouts quickly and all on your own without complicated frameworks or non-semantic class names. It&#8217;s so easy that you might never use a framework for layout again.</p>
<h3><a href="http://thatcoolguy.github.com/gridless-boilerplate/">Gridless</a></h3>
<p>Gridless is an optionated HTML5 and CSS3 boilerplate for making mobile first responsive, cross-browser websites with beautiful typography. It doesn&#8217;t come with any predefined grid systems or non-semantic classes.</p>
<h3><a href="http://www.stacklayout.com/index.html">Stack Layout</a></h3>
<p> A flexible width, component based CSS layout system that makes heavy uses of inline-block elements. </p>
<h3><a href="http://html5boilerplate.com/">HTML5 Boilerplate</a></h3>
<p>HTML5 Boilerplate is quickly becoming the standard starting point for modern web design projects. Last I checked it has everything you could possibly want with the exclusion of a grid system. </p>
<h2>Old School Frameworks</h2>
<p>These are the grandpa grids that have been around for years now. A few of them are really starting to show their age so you may or may not want to use them today.</p>
<h3><a href="http://www.blueprintcss.org/">Blueprint</a></h3>
<p>Blueprint is a CSS framework, which aims to cut down on your development time. It gives you a solid foundation to build your project on top of, with an easy-to-use grid, sensible typography, useful plugins, and even a stylesheet for printing.</p>
<div class="tutorialimage"><a href="http://www.blueprintcss.org/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-1.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://960.gs/">960.gs</a></h3>
<p>960.gs is where most people start when they get into CSS frameworks and grid systems. It&#8217;s still quite popular and many of the newer frameworks are based at least partially on the work here.</p>
<div class="tutorialimage"><a href="http://960.gs/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-2.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.designinfluences.com/fluid960gs/">Fluid 960 Grid System</a></h3>
<p>A popular variant of 960.gs with a fluid layout that automatically adjusts its width depending on the browser window size. </p>
<div class="tutorialimage"><a href="http://www.designinfluences.com/fluid960gs/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-3.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.yaml.de/en/">YAML</a></h3>
<p>&#8220;Yet Another Multicolumn Layout&#8221; (YAML) is an (X)HTML/CSS framework for creating modern and flexible floated layouts. The structure is extremely versatile in its programming and absolutely accessible for end users.</p>
<div class="tutorialimage"><a href="http://www.yaml.de/en/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-4.jpg" alt="screenshot" width="510"/></a></div>
<h2>Awesome New(er) Frameworks</h2>
<h3><a href="http://p.erkins.com/">Perkins</a></h3>
<p>Perkins combines the shiny newness of HTML5 and CSS3 with the awesome power of LESS.js to create an ultimate CSS framework. If you love experimenting with futuristic CSS solutions, this is a great framework for you. It uses a variant of the 1KB Grid.</p>
<div class="tutorialimage"><a href="http://p.erkins.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-5.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://lessframework.com/">Less Framework</a></h3>
<p>Less Framework is a responsive CSS grid system for designing adaptive web­sites. It contains 4 layouts and 3 sets of typography presets, all based on a single grid. &#8220;Less&#8221; in this sense shouldn&#8217;t be confused with LESS.js from above. I know, it&#8217;s confusing. They need to name this one something else!</p>
<div class="tutorialimage"><a href="http://lessframework.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-6.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.columnal.com/">Columnal</a></h3>
<p>A responsive CSS grid system helping desktop and mobile browsers play nicely together. Columnal uses its own hybrid grid system that borrows from a few others.</p>
<div class="tutorialimage"><a href="http://www.columnal.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-7.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.getskeleton.com/">Skeleton</a></h3>
<p>Skeleton is an awesome responsive framework that I&#8217;ve written about a couple of times before. If you&#8217;re not sure about the extra time and learning curve involved in responsive design, you should check this out. Skeleton is built loosely on 960.gs.</p>
<div class="tutorialimage"><a href="http://www.getskeleton.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-8.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.52framework.com/">52Framework</a></h3>
<p>A framework that utilizes HTML5, CSS3 and JavaScript to maximize compatibility of modern web development practices across all major browsers. It&#8217;s based on a simple 16 column grid.</p>
<div class="tutorialimage"><a href="http://www.52framework.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-9.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://framework.gregbabula.info/">G5 Framework</a></h3>
<p>(X)HTML5, CSS3, PHP &#038; jQuery Front End Framework. G5 Framework started as a personal project. In an attempt to speed up workflow, reuse the best coding practices &#038; similar coding techniques, the framework serves as a starter file for new websites.</p>
<p>G5 Framework&#8217;s grid is based on <a href="http://cssglobe.com/post/9849/easy-percentage-grid-system-with-html5">Easy Grid</a>. </p>
<div class="tutorialimage"><a href="http://framework.gregbabula.info/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-10.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://cssglobe.com/post/9849/easy-percentage-grid-system-with-html5">Easy Percentage Grid System with HTML5</a></h3>
<p>The main characteristics of this grid system is that all the columns have percentage based width so they adapt to the container element. It means that with using this system you will not have to define a width of each column by hand, you can simply throw it inside any container and the column widths and column gutters will be automatically set.</p>
<div class="tutorialimage"><a href="http://cssglobe.com/post/9849/easy-percentage-grid-system-with-html5"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-11.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://cabincss.com/">Cabin CSS</a></h3>
<p>CSS Frameworks tend to be super bloated. Cabin solves this problem with a modular extension system that allows you to add only what you need. Various grid extensions are supported.</p>
<div class="tutorialimage"><a href="http://cabincss.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-12.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://masonry.desandro.com/">jQuery Masonry</a></h3>
<p>jQuery Masonry isn&#8217;t really a CSS Framework at all, it&#8217;s a JavaScript plugin that allows grid-based designs that use a sort of vertical float system. It&#8217;s an awesome tool that is quite popular right now.</p>
<div class="tutorialimage"><a href="http://masonry.desandro.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-13.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://csswizardry.com/inuitcss/">InuitCSS</a></h3>
<p>This framework has it all: plugins progressive flexible mobile tablet sensible extensible accessible pragmatic functional useful production-ready more. The grid system is customized to your needs.</p>
<div class="tutorialimage"><a href="http://csswizardry.com/inuitcss/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-51.jpg" alt="screenshot" width="510"/></a></div>
<h2>Small Footprint Frameworks</h2>
<h3><a href="http://www.vcarrer.com/2009/06/1-line-css-grid-framework.html">1 line CSS Grid Framework</a></h3>
<p>I thought that a single line CSS Grid sounded nuts, but this guy pulled it off. I&#8217;m not sure how practical it is in the real world but I&#8217;m impressed with the thought that went into it!</p>
<div class="tutorialimage"><a href="http://www.vcarrer.com/2009/06/1-line-css-grid-framework.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-14.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.1kbgrid.com/">1 KB Grid</a></h3>
<p>This is one of my old favorites. It&#8217;s a grid system stripped to its absolute bare essentials, no sixty minute walkthrough video needed. If you don&#8217;t understand CSS grid systems, start here.</p>
<div class="tutorialimage"><a href="http://www.1kbgrid.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-16.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.tinyfluidgrid.com/">Tiny Fluid Grid</a></h3>
<p>Just like the 1KB grid only fluid for added fun. </p>
<div class="tutorialimage"><a href="http://www.tinyfluidgrid.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-15.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://billyshall.com/slimcss">Slim CSS</a></h3>
<p>SlimCSS is a light CSS Framework thats sets a solid cross-browser foundation with many essential features while staying as small as possible.</p>
<div class="tutorialimage"><a href="http://billyshall.com/slimcss"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-17.jpg" alt="screenshot" width="510"/></a></div>
<h2>Other Frameworks</h2>
<h3><a href="http://gravityframework.com/">Gravity</a></h3>
<p>Gravity is a SASS based framework for making powerful, easily maintainable HTML5 websites. It helps you rapidly prototype your ideas and will generally make your life much easier.</p>
<div class="tutorialimage"><a href="http://gravityframework.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-18.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://cssgrid.net/">1140 Grid</a></h3>
<p>The 1140 grid fits perfectly into a 1280 monitor. On smaller monitors it becomes fluid and adapts to the width of the browser.</p>
<p>Beyond a certain point it uses media queries to serve up a mobile version, which essentially stacks all the columns on top of each other so the flow of information still makes sense.</p>
<div class="tutorialimage"><a href="http://cssgrid.net/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-19.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://thesquaregrid.com/">The Square Grid</a></h3>
<p>A simple CSS framework for designers and developers, based on 35 equal-width columns. It aims to cut down on development time and help you create beautiful-structured websites.</p>
<div class="tutorialimage"><a href="http://thesquaregrid.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-20.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.fluidgrid.net/">Fluid Grid</a></h3>
<p>Fluid Grid is a new grid system that works the same way as Blueprint or 960, but with any page width, even fluid layouts. It is based only on CSS.</p>
<div class="tutorialimage"><a href="http://www.fluidgrid.net/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-22.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.ez-css.org/">EZ-CSS</a></h3>
<p>EZ CSS is a completely different kind of grid framework. It uses a unique module system that allows you to copy, paste and nest simple layouts to create complex pages. It&#8217;s a little hard to wrap your head around but a really brilliant use of CSS.</p>
<div class="tutorialimage"><a href="http://www.ez-css.org/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-23.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.frontendmatters.com/projects/fem-css-framework/">FEM CSS Framework</a></h3>
<p>FEM CSS Framework is a 960px width + 12 column grid system + CSS common styles, to easy and fast develop web layouts.</p>
<p>It is based in the 960 Grid System, but with a twist in the philosophy to make it more flexible and faster to play with boxes.</p>
<div class="tutorialimage"><a href="http://www.frontendmatters.com/projects/fem-css-framework/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-24.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://elasticss.com/">Elastic CSS</a></h3>
<p>A simple css framework to layout web-based interfaces, based on the printed layout techniques of 4 columns but with capabilities to unlimited column combinations. and capacity to make elastic, fixed and liquid layout easily.</p>
<div class="tutorialimage"><a href="http://elasticss.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-25.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://atatonic.timbenniks.nl/about.html">Atatonic CSS</a></h3>
<p>This framework is mostly aimed at typography, but there is a very lightweight grid system in place as well.</p>
<div class="tutorialimage"><a href="http://atatonic.timbenniks.nl/about.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-26.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://baselinecss.com/">Baseline</a></h3>
<p>Baseline makes it easy to develop a website with a pleasing grid and good typography. The grid in Baseline is composed of 4 basic columns, for more flexibility each column can be divided in 2 units.</p>
<div class="tutorialimage"><a href="http://baselinecss.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-27.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://code.google.com/p/emastic/">Emastic</a></h3>
<p>A lightweight fluid grid CSS framework with a focus on typography. </p>
<div class="tutorialimage"><a href="http://code.google.com/p/emastic/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-28.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://code.google.com/p/the-golden-grid/">Golden Grid</a></h3>
<p>The Golden Grid is a web grid system. It &#8216;s a product of the search for the perfect modern grid system. It &#8216;s meant to be a CSS tool for grid based web sites.</p>
<div class="tutorialimage"><a href="http://code.google.com/p/the-golden-grid/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-29.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://colingourlay.github.com/frak/">Frak</a></h3>
<p>Frak is a CSS framework for creating fluid grids. It has an interesting concept that involved using multipliers as class names.</p>
<div class="tutorialimage"><a href="http://colingourlay.github.com/frak/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-31.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://easyframework.com/">Easy Framework</a></h3>
<p>Easy is a CSS/HTML/JavaScript framework started as a personal project and then grew into something more. The idea behind it is to reduce the amount of time spent on setting up the basic master HTML template by reusing the same coding techniques. Includes a simple percentage-based grid system.</p>
<div class="tutorialimage"><a href="http://easyframework.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-32.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://brajeshwar.com/2011/grid-a-minimal-css-grid-utility/">Grid</a></h3>
<p>Grid a simple and minimal fluid grid system that can flow inside any fluid or fixed container or play good with another Grid system.</p>
<div class="tutorialimage"><a href="http://brajeshwar.com/2011/grid-a-minimal-css-grid-utility/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-33.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.520grid.com/">520 Grid</a></h3>
<p>A grid system for designing Facebook pages, crazy but true.</p>
<div class="tutorialimage"><a href="http://www.520grid.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-34.jpg" alt="screenshot" width="510"/></a></div>
<h2>Tools and Grid Builders</h2>
<h3><a href="http://gridcalculator.dk/#/960/4/20/20">Grid Calculator</a></h3>
<p>A really awesome grid calculator with Photoshop and Illustrator template support.</p>
<div class="tutorialimage"><a href="http://gridcalculator.dk/#/960/4/20/20"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-35.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.problem.se/labs/gridcalc/">Grid Calculator and Generator</a></h3>
<p>GridCalc is a easy to use grid calculator. Just enter the desired width of your page and an aproximate range for your column and gutter width and the calculator will give you all the possible combinations within the limits you entered.</p>
<div class="tutorialimage"><a href="http://www.problem.se/labs/gridcalc/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-36.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.cameronmcefee.com/guideguide/">GuideGuide</a></h3>
<p>GuideGuide is my new favorite Photoshop plugin. This free tool automatically places guides in your Photoshop document based on your input. </p>
<div class="tutorialimage"><a href="http://www.cameronmcefee.com/guideguide/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-37.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.3x4grid.com/index.html">3&#215;4 Grid Builder</a></h3>
<p>Grid Builder enables you to easily build an HTML grid with a simple drag<br />
and drop interface. It&#8217;s a really interesting tool that allows you to create custom grids for each project.</p>
<div class="tutorialimage"><a href="http://www.3x4grid.com/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-38.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://gridr.atomeye.com/">Gridr Buildrrr</a></h3>
<p>A super simple and effective custom grid builder.</p>
<div class="tutorialimage"><a href="http://gridr.atomeye.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-39.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://toki-woki.net/p/Boks/">Boks</a></h3>
<p>A really great and under appreciated tool that allows you to build custom implementations of Blueprint. Check out my tutorial <a href="http://designshack.net/articles/css/rapid-blueprint-css-layout-with-boks/">here</a>.</p>
<div class="tutorialimage"><a href="http://toki-woki.net/p/Boks/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-40.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.spry-soft.com/grids/">Variable Grid System</a></h3>
<p>The variable grid system is a quick way to generate an underlying CSS grid for your site. The CSS generated file is based on the 960 Grid System.</p>
<div class="tutorialimage"><a href="http://www.spry-soft.com/grids/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-41.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.zurb.com/playground/css-grid-builder">ZURB CSS Grid Builder</a></h3>
<p>A great grid builder that dishes out a really simple grid with a tiny footprint. </p>
<div class="tutorialimage"><a href="http://www.zurb.com/playground/css-grid-builder"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-42.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://griddle.it/">Griddle</a></h3>
<p>Want to use a grid-based design without a framework? This tool creates a custom background image that makes it easy to achieve grid layout on your own.</p>
<p>Just put your dimensions after our URL to get a background guide image to work with in your browser. Grids are created on the fly, so any combination should work.</p>
<div class="tutorialimage"><a href="http://griddle.it/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-44.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://gridulator.com/">Gridulator</a></h3>
<p>Another background image tool like Griddle. The main difference being that Griddle generates a URL for you to drop in and this gives you an actual image (I like Griddle better).</p>
<div class="tutorialimage"><a href="http://gridulator.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-43.jpg" alt="screenshot" width="510"/></a></div>
<h2>Grid Lover Sites and Must-Read Articles</h2>
<h3><a href="http://grid-based.com/">Grid Based</a></h3>
<p>A web design gallery full of awesome examples of grid-based design.</p>
<div class="tutorialimage"><a href="http://grid-based.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-21.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.designbygrid.com/">Design By Grid</a></h3>
<p>Another great site dedicated to grid-based tools, articles and other resources. </p>
<div class="tutorialimage"><a href="http://www.designbygrid.com/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-46.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.thegridsystem.org/">The Grid System</a></h3>
<p>A one-stop shop for all things grid-related. It&#8217;s an old source but it looks like it&#8217;s still updated regularly. </p>
<div class="tutorialimage"><a href="http://www.thegridsystem.org/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-30.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://designinformer.com/2010/grid-based-web-design-simplified/">Grid Based Design Simplified</a></h3>
<p>An unbeatable primer on grid-based design fundamentals. This should be step one in your grid design quest.</p>
<div class="tutorialimage"><a href="http://designinformer.com/2010/grid-based-web-design-simplified/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-47.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://sixrevisions.com/web_design/the-960-grid-system-made-easy/">The 960 Grid System Made Easy</a></h3>
<p>An complete beginner&#8217;s introduction to the 960 grid system by yours truly. </p>
<div class="tutorialimage"><a href="http://sixrevisions.com/web_design/the-960-grid-system-made-easy/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-48.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.smashingmagazine.com/2007/04/14/designing-with-grid-based-approach/">Designing With Grid-Based Approach</a></h3>
<p>An older Smashing Mag article, but it still has tons of great resources and information to check out. </p>
<div class="tutorialimage"><a href="http://www.smashingmagazine.com/2007/04/14/designing-with-grid-based-approach/"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-50.jpg" alt="screenshot" width="510"/></a></div>
<h3><a href="http://www.markboulton.co.uk/journal/comments/rethinking-css-grids">Rethinking CSS Grids</a></h3>
<p>Mark Boulton discusses how native CSS support for grids should work. A great read!</p>
<div class="tutorialimage"><a href="http://www.markboulton.co.uk/journal/comments/rethinking-css-grids"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/gridres-49.jpg" alt="screenshot" width="510"/></a></div>
<h2>Conclusion</h2>
<p>I hope you enjoyed this massive collection and have enough grid-based design resources to keep you occupied for months on end.</p>
<p>Leave a comment below and let us know what you think of the tools and resources above. Do you use any grid frameworks? Which ones and why?</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/layouts/the-ultimate-collection-of-50-resources-for-grid-lovers/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Helpful Tips &amp; Tools for Web Design Experiments</title>
		<link>http://designshack.net/articles/css/helpful-tips-tools-for-web-design-experiments/</link>
		<comments>http://designshack.net/articles/css/helpful-tips-tools-for-web-design-experiments/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 15:45:12 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=22314</guid>
		<description><![CDATA[Today&#8217;s article encourages you to get into the habit of devoting time to little experiments. Testing ideas and solving problems in a low-pressure and possibly even fun environment can massively boost your education and lead to awesome innovation. We&#8217;ll start with some benefits and tips for experimenting with web development projects and finish up with [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s article encourages you to get into the habit of devoting time to little experiments. Testing ideas and solving problems in a low-pressure and possibly even fun environment can massively boost your education and lead to awesome innovation.</p>
<p>We&#8217;ll start with some benefits and tips for experimenting with web development projects and finish up with a brief look at a few of the tools that I personally use to compose my own experiments. Let&#8217;s get started!</p>
<p><span id="more-22314"></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 Benefits of Experimentation</h2>
<p>Experimentation is a powerful thing. In fact, I would call it an absolutely crucial element in the continuing education of any web developer, whether you&#8217;ve been at it for ten days or ten years. All the web design knowledge in the world won&#8217;t mean squat if you don&#8217;t jump in and get your hands dirty. </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;The absolute best way for me to learn anything in this field is to fire up a text editor and give it a shot myself.&#8221;
</div>
<p></ br></p>
<p>I regularly read web design books and I at least browse, if not completely consume several web design tutorials daily. These are great resources, however, the absolute best way for me to learn anything in this field is to fire up a text editor and give it a shot myself. </p>
<p>Theory and instruction seem to hold a fairly temporary place in my brain, but a hands-on project burrows itself deeply into my long-term memory. The reason is usually quite simple: frustration. The truth is, I regularly fail when trying to accomplish a specific idea or experiment. More often than not things just don&#8217;t work as smoothly as I imagine they will and the result is me sitting and tinkering with a problem for hours on end. </p>
<p>Frustration challenges me. Once faced with a problem that I can&#8217;t immediately solve, I resolve to beat it at any cost. The project itself is of little or no consequence, it&#8217;s the act of working things out that forces me to increase my knowledge base, which in turn helps in all future projects going forward.</p>
<h2>Tips for Experimenting</h2>
<p>Before we take a look at some of the tools that I personally use to quickly hash out my ideas, let&#8217;s go over some basic things to keep in mind as you embark on your own web development experiments.</p>
<h3>You Don&#8217;t Necessarily Need a Goal</h3>
<p>It absolutely helps to have a goal or destination in mind when fiddling around with some code, but in truth you shouldn&#8217;t avoid the practice just because you don&#8217;t have some grand idea or quandary.</p>
<p>Writers often engage in this exercise where they simply sit down and write down their thoughts as they come, it&#8217;s a great habit to get into and can really generate some solid writing ideas. As a developer, you should try the same thing. If you&#8217;re bored one afternoon and have thirty minutes to kill, just start coding to see where it takes you. This sounds sinfully boring to outsiders but trust me, if you&#8217;re in the right profession, you&#8217;ll love every minute of it.</p>
<h3>Dig Around in Other People&#8217;s Code</h3>
<p>You don&#8217;t have to start from scratch when experimenting, one of the absolute best ways to pick up new techniques is to crack open someone else&#8217;s code to see what makes it tick. Once you&#8217;re in, don&#8217;t just browse, start changing things around and commenting sections out to see how the page responds. Always remember to ask &#8220;why?&#8221; when you see something you don&#8217;t understand!</p>
<p>Some great places to start are pre-built frameworks and boilerplates such as the <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a>. These types of tools are created for easy browsing so in addition to being quite advanced, they also tend to be extremely well documented and organized. </p>
<h3>Forget the Rules</h3>
<p>When you&#8217;re coding a professional website, make sure to be on your best behavior with valid, semantic code and cross-browser compatibility. When you&#8217;re experimenting however, don&#8217;t be afraid to toss caution to the wind and try anything that comes to mind.</p>
<p>In solving a problem, it&#8217;s important to know what works and why, even if your solution turns out to be unacceptable in a live web environment, it might help you reach one that is.</p>
<p>Further, between HTML5 and CSS3, there are a ton of new techniques out there just waiting for you to try out to get a glimpse of web design in the future. Many of them only work on two browsers or less but that doesn&#8217;t mean it&#8217;s not worth it to dig in and see how they work!</p>
<p>Once you&#8217;re finished creating your Frankenstein web monster, run it through a validator or lint tool to see some explanations of why it isn&#8217;t correct and suggestions for how to fix it.</p>
<h3>Beat the Tutorial</h3>
<p>Another great catalyst for experimentation is a web design tutorial like those that you see on this site and other. Any time you see one of these, browse through it and ask yourself whether or not the solution presented is the best one.</p>
<p>Don&#8217;t just mindlessly follow the instructions, think about how you can improve the process by cutting down on inefficiencies. The competitive among you will find that, when faced with an opponent that you&#8217;re trying to best, you&#8217;ll be driven much further than you typically would. </p>
<h2>Tools for Experimenting</h2>
<p>Rather than give you a huge list of resources that you have to sort through yourself to find the real gems, I decided to cut down the offering this time and present only those tools that I personally use for experimentation. </p>
<p>The tools below are quite similar in concept but differ enough that I find myself using each for different things. As you try them out and get a feel for each of them you&#8217;ll see what I mean.</p>
<h3><a href="http://macrabbit.com/espresso/">Espresso for Mac</a></h3>
<p>Let&#8217;s start off with the only non-free resource on the list. Espresso isn&#8217;t simply a tool for experimentation, it&#8217;s a full on professional IDE that will run you around $80. If you&#8217;re a professional web designer though, it&#8217;s worth every penny.</p>
<p>There are a million reasons that it&#8217;s great for acting as your primary coding environment, but the main reason that it&#8217;s great for experimenting is the live preview window. As you code, the HTML preview updates in real time without a manual refresh. </p>
<p>Use <a href="http://mizage.com/divvy/">Divvy</a> or some similar tool to split your screen real estate between your code and preview windows and you&#8217;ve got yourself an unbeatable experimentation workflow. Another awesome benefit here that you often won&#8217;t find in free online tools is auto-complete, which really does save you loads of typing time and will allow you to bust out those experiments in a third of the time.</p>
<p>If you&#8217;re already an Espresso fan, check out the <a href="http://macrabbit.com/espresso/2/">Kaboom release of Espresso 2</a>!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/exp-ds-1.jpg" alt="screenshot" width="510"/></div>
<h3><a href="http://cssdesk.com/">CSSDesk</a></h3>
<p>Want a coding environment that updates live but won&#8217;t cost you a dime? Check out CSSDesk. This awesome little tool is comprised of three main areas: CSS, HTML and preview. As you code in the little expandable drawer on the left side of the screen, the preview on the right updates in real time, making it a fantastic way to quickly try out any web design ideas you may have.</p>
<p>CSSDesk is extremely useful and has some really great features including the ability to share or download your creations. One unique thing that I haven&#8217;t seen anywhere else is the ability to customize the background for your experiments. This is really great when you&#8217;re not coding an entire page but instead want to focus on a single item.</p>
<p>You&#8217;ll also love the benefits of line numbering, code highlighting and the ability to hide the code drawer completely to see your experiment in the full window size. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/exp-ds-2.jpg" alt="screenshot" width="510"/></div>
<h3><a href="http://jsfiddle.net/">jsFiddle</a></h3>
<p>jsFiddle is a lot like CSSDesk, only with a major boost in functionality (which can be a pro or con for a simple experiment). For starters, as the name implies, there&#8217;s a heavy emphasis on JavaScript here. However, you don&#8217;t have to write a single line of JavaScript for this to be helpful. </p>
<p>In jsFiddle, you have four resizable areas, one each for HTML, CSS, JavaScript and a preview. Unlike the previous two choices, the preview must be manually updated each time you want to view it. </p>
<p>One awesome feature of jsFiddle is the ability to quickly load in popular JavaScript libraries like MooTools and jQuery. You can also save, share and fork your work and there are buttons to tidy up your code and leave comments on the experiments of others. </p>
<p>I really like the simple and effective CSSDesk environment, but in truth jsFiddle is my go-to place online for quick experiments. I simply love this tool and can&#8217;t recommend enough that you make a weekly habit out of taking time to come here and tinker around with ideas or problems that you&#8217;ve been having.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/exp-ds-3.jpg" alt="screenshot" width="510"/></div>
<h2>Conclusion</h2>
<p>To sum up, frequent experimentation is critical to your growth as a web designer and developer. It&#8217;s far too easy to fall into the trap of resorting to the same old methods on every single project that you take on, which can easily result in a stagnation of talent. There&#8217;s nothing more dangerous to a web designer&#8217;s career than falling behind and becoming obsolete! </p>
<p>The tips for experimenting above are aimed primarily at coders but can easily be applied to pixel pushers as well. Here your playground would simply be Photoshop, Illustrator and/or Fireworks, but the general suggestions of freeform experimentation, looking to the work of others for inspiration and breaking your typical habits still apply. </p>
<p>Leave a comment below and let us know how much time you devote to simply playing around and trying new things. How much value do you receive from this time and what tools do you use?</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/helpful-tips-tools-for-web-design-experiments/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Rolling Your Own Grid Layouts on the Fly Without a Framework</title>
		<link>http://designshack.net/articles/css/rolling-your-own-grid-layouts-on-the-fly-without-a-framework/</link>
		<comments>http://designshack.net/articles/css/rolling-your-own-grid-layouts-on-the-fly-without-a-framework/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 17:04:05 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[grid]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=22278</guid>
		<description><![CDATA[Do you hate CSS grid frameworks but love the rapid layout benefits that they provide? Do you struggle with the math and code necessary to create your own flexible multi-column layouts on the fly? Today we&#8217;re going to walk you through creating your own basic, reusable system for creating multiple columns that you can implement [...]]]></description>
			<content:encoded><![CDATA[<p>Do you hate CSS grid frameworks but love the rapid layout benefits that they provide? Do you struggle with the math and code necessary to create your own flexible multi-column layouts on the fly?</p>
<p>Today we&#8217;re going to walk you through creating your own basic, reusable system for creating multiple columns that you can implement anywhere any time with only a few lines of code. No bloated code or non-sematic class names required!</p>
<p><span id="more-22278"></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>Grid Frameworks: Pros and Cons</h2>
<p>I&#8217;m a pretty big fan of CSS grid frameworks. I love downloading them, breaking them open and seeing how they tick. I&#8217;ve written about nearly every good one that I can find here on Design Shack and I&#8217;ll likely continue to do so in the future.</p>
<p>The benefit of grid frameworks is a no-brainer: they make for ridiculous fast layout. If you have a pretty straightforward layout in mind for your site, you can bust it out effortlessly and spend more time enriching your design than struggling with how to make your columns work. </p>
<p>However, CSS grid frameworks have some pretty serious downsides as well. For starters, many of them are quite hefty and go well beyond simple layout classes while seeking to extensively style every default HTML element the world has ever seen, no matter how obscure. This size problem can definitely tend to make the frameworks difficult to wrap your mind around.</p>
<p>Grid frameworks are also fairly fixed. You have to play by their rules or you end up breaking the entire thing. Customizing the code to your own liking can be a long and painful process, which sort of defeats the time-saving idea. </p>
<p>Finally, many coders are real sticklers for semantic code and setting up generic, obscurely-named classes for layout really frustrates them to no end!</p>
<h2>Build Your Own</h2>
<p>As we just clearly laid out, some people love CSS grid frameworks, many absolutely hate them. This article is targeted at the coders that are somewhere in between the two. You like the benefits that you get, such as rapid layout of multiple columns, but you&#8217;re not convinced that these things are really worth all the trouble.</p>
<p>This is especially true for those constructing a fairly simple web page. Sure, it would be nice to have some help with the layout but bringing in an entire framework for a single page is like bringing in a backhoe to plant a sapling. </p>
<p>For these types of projects, it may be better to abandon grid frameworks altogether. However, it may still behoove us to have some sort of system in place for busting out multiple columns on the fly. </p>
<p>The goal here is to set up a reusable system that you can implement to accomplish complicated, multi-column layouts. The system must be concise and not suffer from bloated code. It should not require a huge list of non-semantic classes, many of which you may never use. It should also be flexible and bend to your will with each project rather than backing you into a corner. If you change your mind and suddenly alter the entire width for the site, our grid should reflow itself with zero problems. Finally, implementation should be quick and painless.</p>
<h2>Creating Columns in CSS</h2>
<p>If you&#8217;re just starting out in CSS layout, building a multi-column layout might be a little bit intimidating. Obviously, if it were effortless, we wouldn&#8217;t have so many frameworks that seek to simplify the process!</p>
<p>Let&#8217;s say you want to set up four columns. First you have to take your width into account. Let&#8217;s say you have a 900px wide container. If you divide 900px by four columns you get 225px per column. Pretty simple! However, these columns will all smash up against each other, we need some margins. Unfortunately, margins will bust our layout and expand our columns beyond the parent width.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-3.jpg" alt="screenshot" width="510"/></div>
<p>What we need to do then is figure up the total amount of room needed for margins. Let&#8217;s say we want the first, second and third column each to have a <em>margin-right</em> of three pixels. Three pixels times three columns equals nine pixels for margins. Now we simply take nine from our width (900 &#8211; 9 = 891) and then divide by four columns to come up with 222.75px for each of the four columns. </p>
<h3>Huh?</h3>
<p>This obviously involved a little bit of math on our part. It&#8217;s not exactly college level stuff but it&#8217;s also not fun to do this every time we need a few columns (the math is also pretty ugly). Further, as soon as we change the total width of our container, this entire thing breaks and we have to start over! </p>
<p>So how do we make it so that when the parent changes, the children follow?</p>
<h2>Use Percents Instead</h2>
<p>Pixel values are case-specific and too precise to use on something that we want to be recyclable. If we substitute percents, our math becomes easier and our grid will be smart enough to adapt to a changing parent container. Essentially, we&#8217;ll be building a fluid grid.</p>
<h3>Create a Grid Calculator</h3>
<p>If we want fast implementation, we can&#8217;t be thinking over all this complicated math every time! Instead of running all of these numbers in our heads, let&#8217;s set up a tool to do all the work for us. It&#8217;s pretty simple with a tool called <a href="http://tinyurl.com/3deywhy">Instacalc</a>.</p>
<p>Instacalc is pretty much a fancy calculator with some minor spreadsheet capabilities. What we get here is the ability to set up reusable formulas for figuring out our columns system. You only have to do this once mind you, once we set it up the first time, you can save the calculator and come back whenever you need it!</p>
<p>Here&#8217;s the setup that I used. The first field requires you to input the number of columns and the second asks for a margin value (this will be in percent). The rest is automated to give you the results that you need. The third field figures out your total margin and the fourth tells you the column width that you need.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-2.jpg" alt="screenshot" width="510"/></div>
<p>If you don&#8217;t want to set this up, don&#8217;t bother! Just use <a href="http://tinyurl.com/3deywhy">mine</a>. With this in place, we can easily calculate the widths needed for the four column layout we attempted above. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-4.jpg" alt="screenshot" width="510"/></div>
<p>Now, if we want to change to a three column layout, all we have to do is type &#8220;3&#8243; in the first field of our calculator. The rest is taken care of for us. This takes all the work out of figuring out multi-column layouts. Simply input a number for your columns and a number for your margin and you get everything you need. Sometimes you get some sloppy numbers as a result, but honestly I&#8217;ve found that there&#8217;s absolutely no problem with setting your columns widths at &#8220;30.667%&#8221;.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-5.jpg" alt="screenshot" width="510"/></div>
<h2>Build It!</h2>
<p>Enough theory, let&#8217;s build this sucker. All of the stuff above sounds like a ton of work, but honestly it&#8217;s way more work to explain it than to build it!</p>
<p>Let&#8217;s say we want four columns of text explaining four features on our website. The HTML for this is pretty easy, just create a wrapper for the section as a whole and a div for each column. I also threw a &#8220;last&#8221; class on the last column to help us clear the margin. </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;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;featuresColumn&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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;featuresColumn&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>
    
<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;featuresColumn&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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;featuresColumn last&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>
    
<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 for the CSS. First, we set a width on the wrapper and set the <em>overflow</em> to <em>hidden</em>. Next, we simply style the features class with the math that our calculator spits out. It&#8217;s important to note once more that since we have this calculator already set up, we don&#8217;t have to run a single calculation in our heads. Just type in the values and grab what the calculator gives us.</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;">.wrapper</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.featuresColumn</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> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">22%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<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>See how little code this is? In place of a gigantic framework we have a few simple declarations that anyone can read. The result is a nice little four column layout that adjusts perfectly to any scenario.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-6.jpg" alt="screenshot" width="510"/></div>
<p>From here we can change our width to anything we want and the grid will fix itself. Want to switch to 960px wide? Simply change the width of the wrapper.</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;">.wrapper</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">960px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.featuresColumn</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> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">22%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<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>If you want a nice fluid grid, change the width of the wrapper to a percent. Now as you adjust the browser size, your columns will automatically adjust.</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;">.wrapper</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">90%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.featuresColumn</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> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">22%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<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>
<h2>Combining Columns</h2>
<p>The clever among you are already saying &#8220;not so fast&#8221;. The problem we&#8217;ve run into from here is that our columns all have to be the same width. For example, what if we want to combine the last two columns of our layout into one wide column?</p>
<p>All we have to do for this is set up a formula in Instacalc that combines two columns and takes away the margin of one of them. Like the rest, this is a one-time thing that you can use again and again. Here I made one formula for combining two columns and one for combining three. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-7.jpg" alt="screenshot" width="510"/></div>
<h3>The Code</h3>
<p>The HTML for this is exactly like last time, only we have three columns instead of four.</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;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;featuresColumn&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;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;featuresColumn&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>
    
    <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;featuresColumnWide last&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>
    
<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 again, we just plug in the numbers from our calculator and we get a nice, concise chunk of CSS that accomplishes exactly what we need it to.</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;">.wrapper</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">700px</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;">3%</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.featuresColumn</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> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">22%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.featuresColumnWide</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> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">48%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<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;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Here&#8217;s the resulting layout with the last column being twice as wide as the first two. Using this method you can slice and dice up an endless combination of different widths that you can apply across all different sections of your site. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/cssgrid-8.jpg" alt="screenshot" width="510"/></div>
<h3>Play With It</h3>
<p>I definitely encourage you to jump into this code and get your hands dirty. I&#8217;ve set up a live playground over at <a href="http://jsfiddle.net/secondfre/rYaQy/">JSFiddle</a> for you to see these examples live and edit them to your own liking. </p>
<p><strong><a href="http://jsfiddle.net/secondfre/rYaQy/">Click here to launch demo</a></strong></p>
<h2>Conclusion</h2>
<p>We had a number of various goals when we started this project. We set out to build a basic grid system that is flexible enough to be implemented in a container of any width, even if that container changes size. The CSS had to be extremely brief and allow for semantic class naming. Finally, implementation had to be fast.</p>
<p>Though it&#8217;s definitely a bit complicated to wrap your head around at first, our system accomplishes all of these goals. You may argue that there&#8217;s way too much math to call it easy but in truth I&#8217;ve given you the formulas and the <a href="http://tinyurl.com/3deywhy">saved calculator</a> that you need. The only work necessary on your part is to input two numbers each time you want to create a new layout!</p>
<p>This article is by no means a recommendation that you should always use this system to build multi-column layouts. It&#8217;s merely an attempt to show you that you don&#8217;t have to be dependent on someone else&#8217;s complicated and bloated framework. With a little bit of setup and ingenuity, multi-column layouts can be accomplished on an as-needed basis with very little effort!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/rolling-your-own-grid-layouts-on-the-fly-without-a-framework/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>3 Must-Learn CSS Techniques for Perfect Web Typography</title>
		<link>http://designshack.net/articles/css/3-must-learn-css-techniques-for-perfect-web-typography/</link>
		<comments>http://designshack.net/articles/css/3-must-learn-css-techniques-for-perfect-web-typography/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 16:52:55 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=22252</guid>
		<description><![CDATA[This article presents an extremely useful set of tips and best practices for those who are still fairly new to working with typography on the web. We&#8217;ll go over the most popular methods for embedding web fonts, sizing fonts and setting a solid line-height. Like the article? Be sure to subscribe to our RSS feed [...]]]></description>
			<content:encoded><![CDATA[<p>This article presents an extremely useful set of tips and best practices for those who are still fairly new to working with typography on the web.</p>
<p>We&#8217;ll go over the most popular methods for embedding web fonts, sizing fonts and setting a solid line-height.</p>
<p><span id="more-22252"></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>Web Typography: The Basics</h2>
<p>I started my design career in print so one of the most jarring transitions to the web-based mindset for me was in the area of typography. For print design, I can use any font I want on any piece as long as I own it and it is resident on my machine. Further, no one really cares how I size my fonts, as long as it prints big enough!</p>
<p>This article contains some techniques that I wish I had known right off the bat and had to learn the hard way through egregious errors and others that I&#8217;m only just now learning about!</p>
<p>Each of these three techniques might seem pretty basic to a pro, and are even likely to be debated by some, but I definitely recommend that anyone new to web design try to get a firm grasp of all these concepts so that you can choose a defendable position for how you set up your type online.</p>
<h2>Embedding Web Fonts: Use @font-face</h2>
<p>A year or two ago the web font game was pretty uncertain. Everyone knew a revolution was coming but there were a number of various techniques that were being pursued and few were certain as to where we would end up.</p>
<p>Fast-forward to now, a single solution has been widely agreed upon to be the best for many or even most circumstances. If you&#8217;re going to embed custom fonts into a website, @font-face is the way to go. It&#8217;s a pure CSS solution with awesome browser support and unlike Cufon and its cousins, results in perfectly selectable text that works and feels just like a native font. </p>
<h3>Fontspring&#8217;s Bulletproof @font-face Syntax</h3>
<p>This is a perfect example of how best practices in web design are constantly changing. The last I checked, Paul Irish&#8217;s smiley face bulletproof @font-face syntax was the best way to go. However, in researching this article I discovered that a new method has appeared that <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">Paul Irish himself</a> calls &#8220;the best possible solution.&#8221;</p>
<p>The new method is <a href="http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax">Fontspring&#8217;s Bulletproof @Font-Face Syntax</a>, which addresses concern over the lack of support for Android in Irish&#8217;s original technique. </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;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Some Font'</span><span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'SomeFont.eot?'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'eot'</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;">'SomeFont.woff'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'woff'</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;">'SomeFont.ttf'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'truetype'</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>If you&#8217;re wondering about the question mark, it&#8217;s a clever trick to fool IE9 into submission with loading the proper fonts and avoiding a 404 error. For more on how this works, check out <a href="http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax">this post</a>.</p>
<h3>Two Free @font-face Services</h3>
<p>If you&#8217;re looking to embed free custom fonts into your web page, the absolute easiest way that I&#8217;ve found is to use <a href="http://www.google.com/webfonts/v2">Google Web Fonts</a>. This amazing service contains over 180 font families and requires zero file downloads on your part. Just browse the library, choose the fonts you want, then copy and paste the code snippets you&#8217;re given. It couldn&#8217;t be easier!</p>
<p>As an alternative, I always recommend <a href="http://www.fontsquirrel.com/">FontSquirrel</a>. Here you have to download @font-face kits, which is a little more work, but the payoff is an unbeatable collection of beautiful free fonts and the ability to upload a single font file of your own which will automatically be converted into several formats and turned into a usable @font-face kit. </p>
<h2>The Font Sizing Dilemma</h2>
<p>While we&#8217;re on the subject of fonts, let&#8217;s briefly discuss font sizing. This is actually a much more fiercely debated topic than the previous one. The truth is, no matter which method you choose, there are plenty of web developers out there who will insist that you&#8217;re doing it wrong!</p>
<p>For the most part, &#8220;em&#8221; seems to be the popular choice. The bottom line is that using &#8220;px&#8221; results in fonts that don&#8217;t scale well in certain browsers. Kyle Schaeffer has an <a href="http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/">interesting article</a> on why using percentages may be a better option, but from what I can tell, most folks are still in favor of &#8220;em&#8221; (or at least an em % hybrid).</p>
<p>Now, since &#8220;em&#8221; can be a bit awkward to work with, a common practice is to set the body font size at 62.5% and then to use &#8220;em&#8221; for everything else. The reason for this is that the results are easy to translate: 1.2em = 12px, 1.4em = 14px, 2.4em = 24px, etc. </p>
<p>Unfortunately, this method causes an odd compounding issue when working with multiple levels of parent/children relationships. Once you get a couple levels in, sizing with &#8220;em&#8221; becomes difficult. The workaround is typically to declare child elements at &#8220;1em&#8221;, but Jonathan Snook might have <a href="http://snook.ca/archives/html_and_css/font-size-with-rem">an even better solution</a>.</p>
<h3>Font Sizing with REM</h3>
<p>The &#8220;rem&#8221; unit is from the CSS3 bag of goodies and sizes fonts relative to the root (html) rather than the parent, which avoids the compounding issue. Here is Snook&#8217;s syntax from his article <a href="http://snook.ca/archives/html_and_css/font-size-with-rem">Font Sizing With REM</a>:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">html <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">62.5%</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-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> 1.4rem<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* =14px */</span>
h1   <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">24px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> 2.4rem<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* =24px */</span></pre></div></div>

</div>
<p></ br></p>
<p>The downside here is that you have to declare backups in &#8220;px&#8221; for, you guessed it, various versions of Internet Explorer. However, the result, according to Snook, is &#8220;consistent and predictable sizing in all browsers, and resizable text in the current versions of all major browsers.&#8221;</p>
<h3>Trouble in Paradise</h3>
<p>As I mentioned above, there&#8217;s always someone around to say &#8220;that&#8217;s not right!&#8221; Developer Harry Roberts recently <a href="http://csswizardry.com/2011/05/font-sizing-with-rem-could-be-avoided/">published an article at CSS Wizardry</a> outlining why sizing with &#8220;rem&#8221; can be avoided. His argument is that the 62.5% trick arises out of laziness on the part of developer (a good thing according to Roberts) but ultimately results in <em>more</em> work (a bad thing). </p>
<p>Roberts goes on to argue against setting arbitrary base font sizes that you don&#8217;t need or even really use and instead encourages setting your base where you want it and styling only the exceptions. </p>
<p>Both developers have perfectly valid points. Snook&#8217;s method is certainly easier to figure out but Roberts makes a somewhat convincing argument for avoiding the 62.5% trick altogether. You should definitely take a close look at both and decide which one you can wrap your mind around!</p>
<h2>Unitless Line Height and Typographic Grids</h2>
<p>The last thing I&#8217;d like to go over is something that I didn&#8217;t even know existed until recently: unitless line height. Eric Meyer explains this idea in detail <a href="http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/">here</a>, but I&#8217;ll give you a quick overview.</p>
<p>The concept here is a little hard to understand but bear with me. Basically, if you declare line-height with a united value such as &#8220;1em&#8221;, that computed value is then automatically passed down to its descendants. Here&#8217;s the example that Eric Meyer cooked up:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">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;">1em</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
small <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>This seems correct enough at first, but the result is actually grabbing the line-height of the child elements from that computed parent value. Therefore, the above code is exactly the same as if you had written this:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">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;">1em</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">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;">15px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
small <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80%</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;">15px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Notice how the line-height stays at 15px for all of the elements. To avoid this, Meyer suggests using unitless line-heights, which are used as a multiplier for the line-height of the child elements. Here&#8217;s the example above rewritten to utilize this technique:</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">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: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
small <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>The result for the code above is exactly the same as that of the code below. From this we can see that our line height of &#8220;1&#8243; is being multiplied by the font-size of the <em>li</em> and <em>small</em> elements and the results are much more predictable.</p>
<div style="overflow: auto; background-color: #eeeeee;">

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">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: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">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;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
small <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80%</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;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<p>Notice here that the line-height stays equal to the font-size of each element. It&#8217;s important to understand that this isn&#8217;t an argument for setting your line-height to exactly your font-size, this was done only for the example. Any number can be used for the line-height and you should experiment to find what works best (the next example uses 1.231).</p>
<h3>HTML5 Boilerplate Approved!</h3>
<p>To see if this is a common practice, I downloaded a copy of <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a> and poked around in the CSS. Sure enough, right away I found a unitless line-height in practice, albeit in a more concise, shorthand version. </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;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span>/<span style="color: #cc66cc;">1.231</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span>small<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* Hack retained to preserve specificity */</span>
select<span style="color: #00AA00;">,</span> input<span style="color: #00AA00;">,</span> textarea<span style="color: #00AA00;">,</span> button <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">99%</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p></ br></p>
<h3>Creating A Typographic Grid</h3>
<p>If you really want to dive into creating nice web typography, check out Richard Rutter&#8217;s article, <a href="http://24ways.org/2006/compose-to-a-vertical-rhythm">&#8220;Compose to a Vertical Rhythm&#8221;</a>, which outlines some useful techniques for juggling font size, line height and margin or padding to create a perfect rhythm for your page.</p>
<p>Chris Coyier over at <a href="http://css-tricks.com/1945-typographic-grid/">CSS-Tricks</a> picks up this technique and takes it further by combining it with, wait for it, unitless line-height! Check out <a href="http://css-tricks.com/1945-typographic-grid/">this page</a> where you can view and download Chris&#8217; prefab typographic grid utilizing these methods. </p>
<h2>Conclusion</h2>
<p>These three lessons can be summed up nicely. First, when you&#8217;re embedding fonts on the web, use @font-face for a highly functional, cross-browser solution. For now, Fontspring&#8217;s syntax seems to be the best solution for formatting your @font-face declarations. Google Web Fonts and Fontsquirrel are the places to go if you want free web fonts that can be easily inserted into any page.</p>
<p>Next, since &#8220;px&#8221; can and does have trouble resizing on various browsers, using &#8220;em&#8221; or &#8220;rem&#8221; for font sizing is probably the best way to go. Using &#8220;rem&#8221; allows for easy use of the 62.5% trick without compounding issues, but there is a decent argument against abandoning this technique, setting an intentional base font-size and doing the math manually for any exceptions such as headers.</p>
<p>Finally, when working with line-height, it&#8217;s a good idea to set up a vertical rhythm or all out typographical grid. One important method to keep in mind is the use of unitless line-heights to simplify inheritance. </p>
<p>These are current best practices as far as I see them. Feel free to leave a fierce rebuttal in the comments for any and all of these techniques. I love digging into and learning about this stuff and if you have alternative methods I want to see them!</p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/css/3-must-learn-css-techniques-for-perfect-web-typography/feed/</wfw:commentRss>
		<slash:comments>10</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>How to Build a Website With Flux 3: A Coder&#8217;s WYSIWYG</title>
		<link>http://designshack.net/articles/html/how-to-build-a-website-with-flux-3-a-coders-wysiwyg/</link>
		<comments>http://designshack.net/articles/html/how-to-build-a-website-with-flux-3-a-coders-wysiwyg/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 19:31:05 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[flux]]></category>
		<category><![CDATA[wysiwyg]]></category>

		<guid isPermaLink="false">http://designshack.co.uk/?p=13207</guid>
		<description><![CDATA[Flux is a WYSIWYG website editor for Macs. Now, before you curse under your breath about how much you hate WYSIWYGs, you should know that Flux is different and is both powerful and flexible enough to be used by professional web developers. Today I&#8217;ll introduce you to Flux by creating a super simple web page [...]]]></description>
			<content:encoded><![CDATA[<div class="tutorialimage"><a href="http://www.theescapers.com/flux/index.html"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-0.jpg" alt="screenshot" width="510"/></a></div>
<p><a href="http://www.theescapers.com/flux/index.html">Flux</a> is a WYSIWYG website editor for Macs. Now, before you curse under your breath about how much you hate WYSIWYGs, you should know that Flux is different and is both powerful and flexible enough to be used by professional web developers. </p>
<p>Today I&#8217;ll introduce you to Flux by creating a super simple web page from scratch (no annoyingly rigid templates). Along the way we&#8217;ll see what a typical workflow looks like and why it just might be the best visual web editor I&#8217;ve ever used. </p>
<p><span id="more-13207"></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 Is Flux Different?</h2>
<p>When I think of a WYSIWYG website editor, two popular applications come to mind. The first is Dreamweaver. Dreamweaver is a ridiculously powerful application, but has a learning curve that&#8217;s quite high. It&#8217;s simply a huge application that may not be worth the trouble for many designers who are already comfortable coding by hand.</p>
<p>The second application that comes to mind is iWeb. iWeb is fun for a few hours, but once you realize how strict the template system is, the idea of using it for professional web design goes out the window. Even its much far superior rival RapidWeaver still seems to push you more towards preset designs and seems like its targeted towards web development novices.</p>
<p>So Dreamweaver is for professionals but has a steep learning curve and iWeb is for laymen and has almost zero learning curve (and consequently zero flexibility), where is the happy medium? Enter Flux.</p>
<p>Flux is a visual web design application for people that hate visual web design applications. The workflow has been carefully crafted to mirror the way you code sites by hand. The best part: it&#8217;s completely flexible. There are some included templates but I&#8217;ve never even really bothered with them because Flux makes it easy to design from the ground up, just like I would if I were writing out the code manually.</p>
<p>Enough talk, let&#8217;s see Flux in action.</p>
<h2>What We&#8217;re Building</h2>
<p>Because I want this to be a really basic introduction, we&#8217;ll keep the design super simple. If I get enough requests in the comments, I can write another more involved and advanced tutorial but for now we&#8217;ll stick with a basic one-page site with very little on it. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-1.jpg" alt="screenshot" width="510"/></div>
<p>Pretty simple right? It almost looks like one of the cheesy templates that come with these types of apps but as I said above, we&#8217;ll be building this from the ground up.</p>
<h2>Step 1: Creating a New Project</h2>
<p>Creating a new project in Flux is a painless procedure. All you do is go to File>New and you&#8217;re on your way. It will ask you where you want to place the files and whether you want Flux to automatically create a basic site structure for you. This includes the following: index.html, main.css and an images folder. In this case that&#8217;s exactly the format that I want to use so I chose to let it set it up for me. If you have a different system that you like better, you can do this manually. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-2.jpg" alt="screenshot" width="510"/></div>
<p>When you double click on the HTML file, you&#8217;ll be taken into the main Flux interface. As you can see, there&#8217;s a lot going on here. In fact, we could spend the entire tutorial just discussing each button and feature. However, to make things less boring, we&#8217;ll go straight to the building and introduce features as they come up. I definitely recommend that you download the demo and poke around the interface to familiarize yourself with it. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-3.jpg" alt="screenshot" width="510"/></div>
<h2>Step 1: Styling The Body</h2>
<p>If you click on the big empty canvas area, you should see a box that becomes highlighted with the word &#8220;body&#8221; in the upper left. This is the empty body structure of your HTML. The first thing we&#8217;ll want to do for our site is add a background to this element. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-4.jpg" alt="screenshot" width="510"/></div>
<p>To do this, click on the Inspector button at the top (looks like a pair of binoculars). This will bring up what is in my opinion, the heart of the app. Here you&#8217;ll create styles and define the look for every element that you create inside of Flux. The output of the Inspector is CSS and all of the controls inside are labeled with the CSS properties you&#8217;re used to working with. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-5.jpg" alt="screenshot" width="510"/></div>
<h3>Adding A Background Color</h3>
<p>If we were coding this site by hand, the first step might be to designate a background color for the body. We&#8217;ll actually be using a repeating image in the next step, but we&#8217;ll want to make sure the background looks right even if the image doesn&#8217;t load. </p>
<p>With the body selected, we&#8217;ll go to the &#8220;Fill&#8221; section on the left of the Inspector. From here, applying a background color is as simple as clicking on the appropriate CSS property and typing in our color; in this case #1f1f21. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-6.jpg" alt="screenshot" width="510"/></div>
<h3>Adding A Background Image</h3>
<p>To add a background image, we basically take the same exact steps and simply navigate to the proper file in the images folder. I used an awesome free background from <a href="http://www.premiumpixels.com/carbon-fibre-photoshop-patterns/">Premium Pixels</a>.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-7.jpg" alt="screenshot" width="510"/></div>
<h2>Step 2: Adding a Container</h2>
<p>To add a container to a site, you would normally just throw in a div, and that&#8217;s exactly how things work in Flux. Click the &#8220;Container&#8221; button at the top and go down to &#8220;Quick Div.&#8221; Make sure that when you do this step, you have the body element selected. In Flux, you always want to select your desired parent object when creating a new element. This ensures that it is inserted into the correct portion of your HTML. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-8.jpg" alt="screenshot" width="510"/></div>
<p>This should create a little empty box with guides on your canvas. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-9.jpg" alt="screenshot" width="510"/></div>
<p>Just as we did before, select the element and open the inspector. Under &#8220;Position &#038; Size&#8221;, set the width to 700px and the height to 810px. Make sure to clear out the default values for &#8220;top&#8221; and &#8220;left&#8221; while you&#8217;re at it. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-10.jpg" alt="screenshot" width="510"/></div>
<h3>Auto-Centering An Element</h3>
<p>Now, if you&#8217;re a web developer you already know exactly how to center this div: set the margins to auto. You can go in and do this manually or simply click on the little gear at the top right of the Inspector and go down to &#8220;Auto Center.&#8221;</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-11.jpg" alt="screenshot" width="510"/></div>
<h3>Adding a Shadow</h3>
<p>At this point you should have the basic frame for the site. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-12.jpg" alt="screenshot" width="510"/></div>
<p>Just for fun, I want to show off some of the Webkit CSS3 features built into Flex. If you click on &#8220;Webkit&#8221; in the inspector, you&#8217;ll see a handful of fun CSS properties: box-shadow, box-reflect, webkit transitions, etc. Unfortunately, there aren&#8217;t any Mozilla equivalents, but you can always drop those into the code manually.</p>
<p>To add a shadow to our container, just click on the property and adjust the settings. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-13.jpg" alt="screenshot" width="510"/></div>
<h2>Inline Styles?</h2>
<p>Keen observers have probably noticed by now that the styles we&#8217;ve been creating are set to &#8220;inline.&#8221; This is one of the quirks of the Flux workflow. For some strange and unknown reason, all of your styles are set to inline by default. It&#8217;s actually a bit easier to setup elements in Flux when they are set to inline so the Flux website recommends that you first set up an element the way you want it in the manner that we have above, then convert the styles into something that will appear in the external stylesheet. </p>
<p>Fear not, this is a quick and pain-free process. Select the object you want to convert, right-click on it and select the &#8220;Create Style with&#8230;&#8221; option. This will bring up the following dialog that will allow you to assign an ID or Class to the object.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-14.jpg" alt="screenshot" width="510"/></div>
<p>Doing this will create a little icon on the left with the ID we just applied. This area is basically an outline of our CSS file. Now when you want to change the properties of that container, you&#8217;ll double click on the icon here to launch the inspector.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-15.jpg" alt="screenshot" width="510"/></div>
<h2>Step 3: The Header</h2>
<p>The steps we just learned lay out the workflow for creating all the content on our page. To add the name of the company to our header, we create another Quick Div, but this time double click inside of it to type inside of it (this essentially creates a &#8220;p&#8221; tag). Once you type out what you want, you can style the text however you like. As you can see below, I&#8217;ve added settings for color, font-family, text-transform, text-align and font-size.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-16.jpg" alt="screenshot" width="510"/></div>
<p>Next, do the same thing for the text below the headline.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-17.jpg" alt="screenshot" width="510"/></div>
<p>That should give you a nice typographical header for your page. Remember to convert both of these elements to external styles just like we did before.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-18.jpg" alt="screenshot" width="510"/></div>
<h2>Step 4: The Image</h2>
<p>Now we&#8217;re ready to throw in our big image. I&#8217;ll use a photo that I shot myself but you can anything you like. </p>
<p>To begin, select the container and create a div that&#8217;s 700px wide and as tall as you need it. Then set the background of the div to your image and the background to no-repeat. With the image div selected, you can use the arrow keys to shuffle it up or down to move it into position, after all this is a WYSIWYG!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-19.jpg" alt="screenshot" width="510"/></div>
<h2>Step 5: Finishing Off The Text</h2>
<p>At this point the tutorial would be quite redundant if we went into too much detail. There&#8217;s really not much left to do beyond creating a few more divs, filling them with text and styling them like we did above. I stayed with the Georgia font theme I had been using and just made my headline larger than the paragraph copy. </p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-20.jpg" alt="screenshot" width="510"/></div>
<p>One thing to note is that to create a link, you simply select an element or block of text and go to Edit>QuickLink. With that, the page should be all finished!</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-1.jpg" alt="screenshot" width="510"/></div>
<h2>What About The Code?</h2>
<p>If we want to look at and edit the code at any point, just hit Command-3 to bring up the code viewer.</p>
<div class="tutorialimage"><img class="alignNone size-full wp-image-1611" src="http://designshack.net/wp-content/uploads/fluxsite-21.jpg" alt="screenshot" width="510"/></div>
<p>Flux spits out nice clean code that fully integrates with the development process. You can do as much or as little as you want with the WYSIWYG interface and do the rest by hand. Since Flux uses only plain old HTML and CSS files, you can even work on the site in your favorite code editor as you build in Flux. The workflow is completely open so that if at any point you just want to do something the way you always have, you&#8217;re free to do so!</p>
<h2>What Else Does Flux Do?</h2>
<p>This tutorial hasn&#8217;t scratched the surface of what Flux can do. Here&#8217;s a few other features to get excited about:</p>
<ul>
<li>Built-in layout modules for fast prototyping</li>
<li>Live Browser View</li>
<li>JavaScript, PHP, and all that jazz</li>
<li>WordPress Theme Support</li>
<li>Reusable Code Snippets</li>
<li>History Palette</li>
<li>Widget palette &#8211; Create easy galleries and jQuery effects</li>
<li>HTML5 Support</li>
<li>Google Font API Support</li>
<li>Tons more that I don&#8217;t even know about yet!</li>
</ul>
<h2>Closing Thoughts</h2>
<p>I first used Flux a couple of versions ago (Flux is now in its third iteration), and loved the idea but wasn&#8217;t crazy about the execution. It felt a little buggy (all that is fixed now) and really didn&#8217;t seem that easy to just pick up and run with.</p>
<p>However, that encounter was quite brief and I&#8217;ve always wanted to go back and really give it a proper run through. I&#8217;ve played with Flux for the past two days and have to say that, once I took the time to figure out the proper workflow, working with Flux was a dream. It definitely takes a little while to figure out all the quirks but once you do they don&#8217;t eat up any time at all and feel quite natural.</p>
<p>At the very least, Flux is awesome for prototyping. Fans of designing in the browser instead of Photoshop will see most of their concerns addressed here as you are forced to design using actual CSS properties and positioning rather than Photoshop effects. My favorite part about the app is that it doesn&#8217;t corner you into using it through the whole process. There aren&#8217;t any Flux project files to worry about, only the files you would normally use to build a site. This means you can switch to a different app or even pass the project off to a colleague or client who neither needs Flux or need ever know you used it. </p>
<p>If you&#8217;re a developer who codes by hand that often dreams of a WYSIWYG that doesn&#8217;t suck and can actually plug into the way you currently work, I highly recommend that you give Flux a shot. It can be a little frustrating at first, but take the time to push through that and figure out how to really use the app properly and I&#8217;ll wager that you might just think it&#8217;s the best WYSIWYG you&#8217;ve ever used. </p>
]]></content:encoded>
			<wfw:commentRss>http://designshack.net/articles/html/how-to-build-a-website-with-flux-3-a-coders-wysiwyg/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Using eCSStender to Clean Up Your CSS</title>
		<link>http://designshack.net/articles/css/using-ecsstender-to-clean-up-your-css/</link>
		<comments>http://designshack.net/articles/css/using-ecsstender-to-clean-up-your-css/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 14:00:50 +0000</pubDate>
		<dc:creator>Joshua Johnson</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[eccstender]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[less]]></category>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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