<?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>Fearless Flyer Web Design &#187; jQuery</title>
	<atom:link href="http://fearlessflyer.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://fearlessflyer.com</link>
	<description>Fearless flyer is a blog that focuses on the latest topics of web design. This includes Wordpress, SEO, Photoshop, jQuery, PHP and CSS. Fearless flyer is owned and operated by Michael Soriano, a seasoned web developer living in Southern California.</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:11:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Create Super Easy jQuery Tabbed Containers</title>
		<link>http://fearlessflyer.com/2012/01/how-to-create-super-easy-jquery-tabbed-containers/</link>
		<comments>http://fearlessflyer.com/2012/01/how-to-create-super-easy-jquery-tabbed-containers/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 18:29:12 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[walkthrough]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2324</guid>
		<description><![CDATA[In this tutorial I&#8217;m going to show you how to create tabbed containers using jQuery. Tabbed containers is an excellent way of presenting your content. Data is organized where only the current tab&#8217;s section is shown. Once the user clicks on the other tabs, its associated content gracefully appears. View Demo Please note that you ]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;m going to show you how to create tabbed containers using jQuery. Tabbed containers is an excellent way of presenting your content. Data is organized where only the current tab&#8217;s section is shown. Once the user clicks on the other tabs, its associated content gracefully appears. </p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/jquery_tabs/">View Demo</a></div>
<p>Please note that you will need to know some HTML / CSS and a little Javascript scripting to follow. Ready to get started? Let&#8217;s begin: </p>
<h3>Set up the HTML:</h3>
<p>First and foremost &#8211; we need the markup. We need this so we know what we are styling and manipulating. We are going to use semantic and valid HTML. In addition, we will keep it as clean as possible &#8211; with no unnecessary DIVs and classes in our code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul id=&quot;tabs&quot;&gt;
      &lt;li&gt;&lt;a href=&quot;#tab1&quot;&gt;Files and Folders&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab2&quot;&gt;User Profiles&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab3&quot;&gt;Contacts&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab4&quot;&gt;Applications&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab5&quot;&gt;Monthly Cost&lt;/a&gt;&lt;/li&gt; 
&lt;/ul&gt;
&lt;div class=&quot;container&quot; id=&quot;tab1&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab2&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab3&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab4&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab5&quot;&gt;
    ...content goes here
&lt;/div&gt;</pre></td></tr></table></div>

<p>As you can see, our markup is pretty self-explanatory. The UL items will be our tabs, while the DIVs below it are the containers. Save your file and view it in the browser: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial1.jpg" alt="tutorial1 How to Create Super Easy jQuery Tabbed Containers" title="tutorial1" width="446" height="399" class="alignnone size-full wp-image-2325" /></p>
<h3>Add Some Sweet Styles:</h3>
<p>I usually like to style the HTML right after. This way &#8211; I can write the script exactly how to behave. Moreover, we can decide if what classes to add via Javascript. </p>
<h6>The Tabs</h6>
<p>Let&#8217;s convert our unordered list into tabs:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#tabs</span> <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;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">28px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eff5f9</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span><span style="color: #993333;">inset</span>  <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</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: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	border-top-left-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>  
	border-top-right-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#tabs</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</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> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> 
	border-top-left-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>  
	border-top-right-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span>  <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#tabs</span> li a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</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;">13px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000000</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;">14px</span> <span style="color: #933;">6px</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">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;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span>  
	border-top-left-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span> 
	border-top-right-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</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;">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;">#ebebeb</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">white</span> <span style="color: #933;">10%</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> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10%</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#ebebeb</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #993333;">white</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span> <span style="color: #933;">-1px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Save your file and view it in the browser: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial2.jpg" alt="tutorial2 How to Create Super Easy jQuery Tabbed Containers" title="tutorial2" width="500" height="284" class="alignnone size-full wp-image-2327" /></p>
<p>Beautiful right? Things are coming along. We also want to add a style for the &#8220;inactive&#8221; state of the tabs. This will be how the tabs will look when they&#8217;re not in focus. Add the code below to your stylesheet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#tabs</span> li a.inactive<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666666</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;">#dedede</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">white</span> <span style="color: #933;">75%</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> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">75%</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#dedede</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #993333;">white</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#tabs</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#tabs</span> li a<span style="color: #6666ff;">.inactive</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</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> <span style="color: #cc00cc;">#dedede</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Notice that I also added a separate style for <em>:hover</em>. To see how these styles look, you have to manually add class &#8220;inactive&#8221; to the anchor tags in our tabs, and refresh your browser: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial3.jpg" alt="tutorial3 How to Create Super Easy jQuery Tabbed Containers" title="tutorial3" width="439" height="236" class="alignnone work size-full wp-image-2328" /></p>
<h6>The Containers</h6>
<p>The containers styles really depend on you. I just added some general rules such as width and appropriate paddings:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.container</span><span style="color: #00AA00;">&#123;</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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">664px</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;">#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: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> 	 
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Now we have a solid look and we can continue with the scripting. Be sure to add some dummy content to your containers before we go on. </p>
<h3>The jQuery</h3>
<p>This part may have the shortest code, but will do a lot of work. Lets include the jQuery library into our page and start our document ready event. Append this code into your HTML:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
    <span style="color: #006600; font-style: italic;">//our script goes here...</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Now we need a way make our tabs inactive and hide the containers. Add the lines of code inside our document ready block:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a:not(:first)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.container:not(:first)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The code above adds the class &#8220;inactive&#8221; to all our our tabs &#8211; except the first one using the &#8220;:not(:first)&#8221; filter. The second line hides all of our container divs &#8211; except the first one, again using the said filter.<br />
Refresh your browser and you shall see the effects: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial4.jpg" alt="tutorial4 How to Create Super Easy jQuery Tabbed Containers" title="tutorial4" width="500" height="428" class="alignnone size-full wp-image-2330" /></p>
<p>Now let&#8217;s add a click handler to our tabs along with the events. Add the lines of code also inside document ready:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> t <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>A lot of things are happening here &#8211; first &#8211; we&#8217;ve established a click handler to our tabs. We also created a variable &#8220;t&#8221; that represents the value of the &#8220;href&#8221; attribute for whichever anchor tag that was clicked. For instance, if the first tab was clicked, then &#8220;t&#8221; will be &#8220;#tab1&#8243;. Then we add class &#8220;inactive&#8221; to all of the tabs, while removing &#8220;inactive&#8221; to whichever one was clicked. Then, we hide all of the containers while fading in the one that is &#8220;t&#8221;, i.e. #tab1 or #tab2 and so on. Return false just prevents the anchor links from their default behavior.</p>
<p>Refresh your browser and try it out. So our tabs are in full action. There is one problem though: when you click the current tab &#8211; it still attempts to hide all the containers and show the current one &#8211; we don&#8217;t want this to happen. Let&#8217;s add a conditional block to our code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//this is the start of our condition </span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		 
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Wrapping our events inside this if block prevents this unwanted behavior. </p>
<h3>Conclusion</h3>
<p>And there you have it. Wasn&#8217;t that easy? Super Easy? The best thing about this code is it doesn&#8217;t use any images. All of the gradients and shadows are CSS3. Also, it is backwards compatible for users without Javascript. It won&#8217;t work as tabs &#8211; but it will show the full content, and the tabs will still lead them to the right area when clicked. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2012/01/how-to-create-super-easy-jquery-tabbed-containers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create Rotating (Full Paged) Background Images with CSS and jQuery</title>
		<link>http://fearlessflyer.com/2011/10/create-rotating-full-paged-background-images-with-css-and-jquery/</link>
		<comments>http://fearlessflyer.com/2011/10/create-rotating-full-paged-background-images-with-css-and-jquery/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 14:30:56 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[fade effect]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[large backgrounds]]></category>
		<category><![CDATA[rotating image]]></category>
		<category><![CDATA[slideshow background]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2207</guid>
		<description><![CDATA[Full page background images on web sites has become more popular than ever. Its a good way to utilize the remaining real estate of the browser, without having to sacrifice content. But what about rotating these images? Wouldn&#8217;t that even be better? This tutorial will walk you through how to create full page background images ]]></description>
			<content:encoded><![CDATA[<p>Full page background images on web sites has become more popular than ever. Its a good way to utilize the remaining real estate of the browser, without having to sacrifice content. But what about rotating these images? Wouldn&#8217;t that even be better? </p>
<p>This tutorial will walk you through how to create full page background images that rotate like a slideshow. We will be using CSS and jQuery &#8211; particularly the nifty <a href="http://jquery.malsup.com/cycle/">cycle plugin</a>. Ready to get started? Let&#8217;s begin:</p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/rotating-bg/">View the Demo</a></div>
<h3>The HTML Markup:</h3>
<p>First we create the background images. Place them in your root folder, in a directory called &#8220;images&#8221;. We wrap them around a special DIV which houses all the images. We need this DIV so we can target it from our script later:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;slideshow&quot;&gt;
&lt;img src=&quot;/images/b1.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;img src=&quot;/images/b2.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;img src=&quot;/images/b3.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;img src=&quot;/images/b4.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;img src=&quot;/images/b5.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;img src=&quot;/images/b6.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;img src=&quot;/images/b7.jpg&quot; class=&quot;bgM&quot;/&gt;
&lt;/div&gt;
&lt;div id=&quot;wrap&quot;&gt;
...your content here
&lt;/div&gt;</pre></td></tr></table></div>

<p>Make sure your image is a good sized horizontal shot. For almost all screen resolutions have wider width vs height. Our images will scale to the width of the screen. The DIV id=&#8221;wrap&#8221; is the container for your content. This is directly underneath our slideshow container. Save your HTML and view it in the browser. You should see a series of images on top of each other. </p>
<h3>The CSS</h3>
<p>Add this code to your page. This will set the images width to span the entire page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#slideshow</span><span style="color: #00AA00;">,</span> img<span style="color: #6666ff;">.bgM</span> <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">min-width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1024px</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</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;">9999</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>View Refresh your page. You should see only the first image. The rest of the images are tucked away underneath the first one. This is what &#8220;z-index&#8221; and &#8220;position&#8221; properties in our code did. Now for the slideshow effect, we use some jQuery magic. </p>
<h3>The jQuery</h3>
<p>Download the jQuery Cycle plugin from <a href="http://jquery.malsup.com/cycle/download.html">here</a>, and place it inside a directory called &#8220;scripts&#8221; in your root folder. Add the jQuery library and a reference to the plugin inside the head section of your HTML:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.6.3.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;scripts/jquery.cycle.all.2.74.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p>Then add this code that will pickup our slideshow DIV, and apply the cycle functionality from our plugin:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#slideshow'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">cycle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				fx<span style="color: #339933;">:</span> <span style="color: #3366CC;">'fade'</span><span style="color: #339933;">,</span>
				pager<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#smallnav'</span><span style="color: #339933;">,</span> 
				pause<span style="color: #339933;">:</span>   <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> 
				speed<span style="color: #339933;">:</span> <span style="color: #CC0000;">1800</span><span style="color: #339933;">,</span>
				timeout<span style="color: #339933;">:</span>  <span style="color: #CC0000;">3500</span> 
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can choose to edit the plugin options by tweaking the above code. For the list of available options such as transition effects, timing and callbacks &#8211; refer to the jQuery Cycle <a href="http://jquery.malsup.com/cycle/options.html">docs</a>.</p>
<h3>Conclusion:</h3>
<p>Now refresh your browser and you should see your background fade into the next image and to another. Like I said, this style can be quite refreshing &#8211; to vary your page from a million other websites out there with large image backgrounds. The only problem with this is when browser is resized, the image stays in the original size and doesn&#8217;t resize on the fly. Maybe one of you guys can improve the image handling with javascript or something.</p>
<p><strong>Bonus Tip:</strong> for added functionality, you can add individual links to the background images by wrapping each image into an anchor tag:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;slideshow&quot;&gt;
&lt;a href=&quot;http://yahoo.com&quot;&gt;&lt;img src=&quot;images/b1.jpg&quot; &lt;/a&gt;
&lt;img src=&quot;images/b3.jpg&quot; class=&quot;bgM&quot;/&gt;
class=&quot;bgM&quot;/&gt;&lt;/a&gt;</pre></td></tr></table></div>

<p>This is especially useful if you&#8217;re using your background as advertising space of some sort (hint hint). </p>
<p>So go on and try it out for yourself. Please leave me a comment below if you have suggestions on how to improve the code, show off your stuff, or simply say hello. </p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/rotating-bg/">View the Demo</a></div>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2011/10/create-rotating-full-paged-background-images-with-css-and-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to create a Subscribe Opt in Box in jQuery</title>
		<link>http://fearlessflyer.com/2011/06/opt-in-box/</link>
		<comments>http://fearlessflyer.com/2011/06/opt-in-box/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 16:43:43 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Opt in Box]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[walkthrough]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2142</guid>
		<description><![CDATA[Recently I had to come up with a solution to the low subscriber issue that I’ve been having. Compared to the number of downloads, I have an extremely low number of RSS, Twitter and Facebook followers. I thought, if I can prompt all visitors with a box that will remind them to follow me – ]]></description>
			<content:encoded><![CDATA[<p>Recently I had to come up with a solution to the low subscriber issue that I’ve been having. Compared to the number of downloads, I have an extremely low number of RSS, Twitter and Facebook followers.  I thought, if I can prompt all visitors with a box that will remind them to follow me – then that would solve my problem. Well, at least a little bit. </p>
<p>To view a demo of what we’re building – click on a download link in my <a href="http://fearlessflyer.com/category/freebies/">freebies </a>section.</p>
<p>An opt-in box is definitely a move forward. It is simple and effective. Of course, we will make it so that it is as &#8220;non-intrusive&#8221; as possible. Ready to get started? Let’s begin. </p>
<h3>Set up the Lightbox</h3>
<p>For our opt in box, there’s nothing more graceful than to add a lightbox effect. I picked up this code from <a href="http://www.cssjockey.com/web-development/tips-tricks/an-easy-way-to-create-light-box-with-jquery-css">CSS Jockey</a> – which was as simple as you can get. </p>
<p>The markup will contain 2 components – the dark overlay for the rest of your page content (hereby called #<strong>darkbg</strong>), and the actual opt in box (called #<strong>lightbox-panel</strong>).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;darkbg&quot;&gt; &lt;/div&gt; 
&nbsp;
&lt;div id=&quot;lightbox-panel&quot;&gt;
&lt;h3&gt;This is our Opt in box&lt;/h3&gt;
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum 
&nbsp;
&lt;a id=&quot;close&quot; href=&quot;#&quot;&gt;close&lt;/a&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Nothing really going on here,  just a couple of DIVs with some content.  View it in the browser to see what we have:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/06/optinbox-1.jpg" style="border:none;" title="How to create a Subscribe Opt in Box in jQuery photo" alt="optinbox 1 How to create a Subscribe Opt in Box in jQuery" /></p>
<p>Next, we add some CSS to see what the box will look like after we’re done. Note that we’re adding this in the head section of our HTML just for demo purposes. In real code – you want to separate markup, scripts and styles.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
  <span style="color: #cc00cc;">#darkbg</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;">#000000</span><span style="color: #00AA00;">;</span>  
     opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.7</span><span style="color: #00AA00;">;</span>  
     filter<span style="color: #00AA00;">:</span>alpha<span style="color: #00AA00;">&#40;</span>opacity<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">70</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">min-width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</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;">100%</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;">1000</span><span style="color: #00AA00;">;</span>  
    <span style="color: #00AA00;">&#125;</span>  
<span style="color: #cc00cc;">#lightbox-panel</span> <span style="color: #00AA00;">&#123;</span>  
     <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-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;">400px</span><span style="color: #00AA00;">;</span>  
     <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</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;">15px</span> <span style="color: #933;">10px</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>  
     border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</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;">1001</span><span style="color: #00AA00;">;</span>  
	 <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</span><span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
	 box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">,</span> <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #933;">100px</span> <span style="color: #cc00cc;">#c9c9c9</span> <span style="color: #993333;">inset</span><span style="color: #00AA00;">;</span>
	 <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	 <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div>

<p>Now refresh your browser and see what the output is:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/06/optinbox-2.jpg" title="How to create a Subscribe Opt in Box in jQuery photo" alt="optinbox 2 How to create a Subscribe Opt in Box in jQuery" /></p>
<p>What a transformation huh? </p>
<p>Now let’s add “<strong>display:none</strong>” to both DIV elements in the style section – so that next time you load the page – you don’t see them.<br />
After this step, we add Javascript to the page, so the DIVs can elegantly appear and disappear when we want it to.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://code.jquery.com/jquery-1.6.1.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#darkbg, #lightbox-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#close&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#darkbg, #lightbox-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>The above code is linking to the jQuery library from the jQuery website. The next set of codes does the following when the document (webpage) is ready:</p>
<p>•	Fade in both DIVs in 300 milliseconds<br />
•	When the anchor tag with the id of “<strong>close</strong>” is clicked, fade out both DIVs in 300 milliseconds</p>
<p>Refresh your browser and you should see the DIVs fade in. Click the “Close” link and it will fade out. </p>
<p>Now we can play with how our Opt in Box enters the page. </p>
<h3>Entrance Effects: </h3>
<p><strong>1)	From the Side:</strong></p>
<p>Right now, our Opt in box fades in – which is already a good enough effect. But I’ve seen some websites that have their Opt in box come in from the side. Here’s how to do that:</p>
<p>In the style section – take out the left property in the #<strong>lightbox-panel</strong> section: <strong> left:50%;  </strong></p>
<p>We’ll add this effect through Javascript like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#lightbox-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>				 
	left<span style="color: #339933;">:</span> <span style="color: #3366CC;">'50%'</span> 					 
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>In the first line of code – make sure you delete the lightbox-panel from the selectors so it doesn’t fade in at the same time as the darkbg.<br />
Now refresh your browser and see the effect.</p>
<p><strong>2)	From the Top:</strong></p>
<p>If you want your box to come from the top – go in the styles section of #lightbox-panel and delete this line of code:   <strong> top:100px;  </strong></p>
<p>Add this in replacement of it &#8211; *Note you may need to adjust this value depending on the size of your box. The taller the box – the larger the negative value is: <strong>margin-top:-400px;</strong>. </p>
<p>Now in the script section – add this code after the first fadeIn function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#lightbox-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>				 
	top<span style="color: #339933;">:</span> <span style="color: #3366CC;">'500px'</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>Refresh your browser and you should see a nice top down effect. </p>
<h3>Content:</h3>
<p>Now although this section is entirely up to you, I did write up what I did for my own Opt in box. See, Opt in boxes are designed to engage your users in one form of activity for marketing purposes. May it be to take a survey, fill out a form (<a href="http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/">which I have a tutorial on</a>), or simply click on a set of links that lead to your Twitter or Facebook accounts etc. </p>
<p>I wanted only to target the people who download my free stuff – right before they download. So I need a way to capture the click events that lead to specific file type – in my case: all zip files. </p>
<p>This is how my code looks:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[href$='.zip']:not(#real)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#darkbg, #lightbox-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
		<span style="color: #003366; font-weight: bold;">var</span> thelink <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a#real'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> thelink<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>thelink<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>Instead of simply activating the box right away – I wrap in around a click event. But not just any click – you notice the line<strong> a[href$=&#39;.zip&#39;]:not(#real)</strong> – that’s called a selector. This means that all files with the .zip extension – unless if it has an id of “real” (I’ll explain later). </p>
<p>The next line <strong>$(&quot;#darkbg, #lightbox-panel&quot;).fadeIn(300);</strong> activates our box.  Notice that we’ve created a variable called “<strong>thelink</strong>”. This variable is whatever value the “<strong>href</strong>” attribute of the link that you clicked. We need this value to transfer to a link onto our Opt in box itself.  Sort of a “go between” between links.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a#real'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> thelink<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>thelink<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above code assigns a new “href” to a link with the id of “<strong>real</strong>” (from above) – which is in our markup in the actual Opt in box itself:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;p&gt;Here is the file: &lt;a href=&quot;&quot; id=&quot;real&quot;&gt;&lt;/a&gt;&lt;/p&gt;</pre></div></div>

<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/06/optinbox-3.jpg" style="border:none;" title="How to create a Subscribe Opt in Box in jQuery photo" alt="optinbox 3 How to create a Subscribe Opt in Box in jQuery" /></p>
<p>Finally, I add a line in the click event of our closing link:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#close-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#darkbg, #lightbox-panel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a#real'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>This <strong>$(&#39;a#real&#39;).attr(&#39;href&#39;, &#39;&#39;).html(&#39;&#39;)</strong>;   makes sure that our anchor with id “<strong>real</strong>” is empty again for next use.</p>
<h3>Conclusion:</h3>
<p>There you go. We have just created a simple, yet elegant Opt in Box. As I&#8217;ve mentioned, to add a contact form in PHP &#8211; <a href="http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/">check out my older post</a> (see the section &#8220;Completing the Contact Form with PHP&#8221;). Also, for an email subscription form &#8211; there&#8217;s no better service than Google&#8217;s Feedburner. Once signed up &#8211; you can use the Email Subscription form they supply &#8211; which comes with verification and captcha mechanisms and such &#8211; all ready to go!</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/06/optinbox-4.jpg" title="How to create a Subscribe Opt in Box in jQuery photo" alt="optinbox 4 How to create a Subscribe Opt in Box in jQuery" /></p>
<p>There is no download for this tutorial because I wanted you to follow the steps and understand the inner workings of the code. Also, if you notice the title &#8220;#1&#8243;, I&#8217;m going to try to write more tutorials such as this one (if you find it useful). So please leave a comment and let me know what you think. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2011/06/opt-in-box/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magazine Style WP Theme &#8211; Agency</title>
		<link>http://fearlessflyer.com/2011/05/magazine-style-wp-theme-agency/</link>
		<comments>http://fearlessflyer.com/2011/05/magazine-style-wp-theme-agency/#comments</comments>
		<pubDate>Mon, 16 May 2011 00:49:01 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Wordpress Themes]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Magazine Style]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[WP Themes]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2127</guid>
		<description><![CDATA[All in all, I think this theme is quite remarkable. Yup, a pat in the back &#8211; a job well done. Agency is what I call it. It is a magazine style theme that puts your content in a beautiful wrapper, complete with subtle page elements that is sure to add elegance to your pages. ]]></description>
			<content:encoded><![CDATA[<p>All in all, I think this theme is quite remarkable. Yup, a pat in the back &#8211; a job well done. Agency is what I call it. It is a magazine style theme that puts your content in a beautiful wrapper, complete with subtle page elements that is sure to add elegance to your pages. This theme is compatible with the latest WordPress release, taking advantage of some its newer features. Let me explain:</p>
<div class="special">Agency has been updated to Version 2. More details can be found in this <a href="http://fearlessflyer.com/2011/12/updated-agency/">post</a></div>
<table>
<tr>
<td>
<div class="viewdemo"><a href="http://agency.fearlessflyer.com/">View the Demo</a></div>
</td>
<td style="padding-left:10px;">
<div class="buylink"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&#038;hosted_button_id=2GQ75EJBWU4YJ">Buy Through Paypal</a></div>
</td>
</tr>
</table>
<h3>Features:</h3>
<ul>
<li><strong>A Custom Slideshow</strong> &#8211; sits in the home page, automatically switches through four images. These images are post thumbnails from posts assigned to a specific category. In other words, the slideshow pulls 4 posts from a category named &#8220;featured&#8221;. You can change the category by editing &#8220;feature.php&#8221; &#8211; look for the variable <strong>$myCat</strong> . </li>
<li><strong>Two Widgetized Sidebars</strong> &#8211; Each sidebar has a width of 140 pixels &#8211; just enough to house small ad spots, text and general widgets .The sidebars also sit on the center of the page as you scroll down.</li>
<li><strong>Custom Gallery Styles with Lightbox</strong> &#8211; The default WordPress gallery style is overridden to match the rest of the theme. Lightbox effect is also applied to all links leading to an image.</li>
<li><strong>Built in Contact Form</strong> &#8211; no need to install a plugin for a simple contact form, its already in the theme. Simply apply the page template &#8220;Contact Form&#8221; into your page</li>
</ul>
<p><a href="http://agency.fearlessflyer.com/"><br />
<img src="http://fearlessflyer.com/main/wp-content/uploads/2011/05/agency-theme.jpg" alt="agency theme Magazine Style WP Theme   Agency" title="agency-theme" width="576" height="777" class="alignnone size-full wp-image-2128" /><br />
</a></p>
<p>The theme also supports the WP 3.0 menu system, gravatars and threaded comments. The thumbnails for each posts, including the images in the slideshow are pulled from the post thumbnails. </p>
<h3>How to Use:</h3>
<p>Installing the theme is just like any other WordPress theme. Simply go to the &#8220;<strong>Appearance</strong>&#8221; > &#8220;<strong>Install Themes</strong>&#8221; section in your admin panel. Click the &#8220;<strong>Upload</strong>&#8221; link &#8211; browse to the theme .zip file and &#8220;<strong>Install Now</strong>&#8220;. </p>
<h6>Adding Post Thumbnails to your Posts:</h6>
<p>To add images to your posts you can use the Post Thumbnail feature of WordPress. Simply go to the post in &#8220;<strong>Edit</strong>&#8221; mode. On the right side of the page &#8211; click on &#8220;<strong>Set Featured Image</strong>&#8220;:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/09/set-as-featured-image.jpg" alt="set as featured image Magazine Style WP Theme   Agency" title="set-as-featured-image" width="412" height="370" class="alignnone work size-full wp-image-2292" /></p>
<p>This will trigger the image uploader. Upload your image and as soon as that&#8217;s done, click the &#8220;<strong>Use as Featured Image</strong>&#8221; link:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/09/uset-as-featured-image.jpg" alt="uset as featured image Magazine Style WP Theme   Agency" title="uset-as-featured-image" width="412" height="370" class="alignnone work size-full wp-image-2293" /></p>
<p>Note that you should keep the file sizes to a smaller size. The resizing script has a maximum size limit. </p>
<h6>How to Activate the Slideshow:</h6>
<p>The slideshow in the homepage pulls 4 posts from a category called &#8220;<strong>featured</strong>&#8221; (If you want to pull from a different category &#8211; see below). Simply go to &#8220;<strong>Categories</strong>&#8221; and one called &#8220;<strong>featured</strong>&#8221; &#8211; add 4 posts under it. </p>
<p>Visit your homepage and you should now see the slideshow area populated with the posts you just assigned to &#8220;Featured&#8221;. Now if you don&#8217;t see an image &#8211; that means you haven&#8217;t assigned a Post Thumbnail &#8211; so read the section above called &#8220;<em>Adding Post Thumbnails to your Posts</em>&#8220;. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/05/agency-slideshow.jpg" alt="agency slideshow Magazine Style WP Theme   Agency" title="agency-slideshow" width="412" height="370" class="alignnone work size-full wp-image-2296" /></p>
<p>*If you want to change the slideshow to pull from another category instead of &#8220;featured&#8221;, go to &#8220;<strong>Appearance</strong>&#8221; > &#8220;<strong>Editor</strong>&#8221; and click &#8220;feature.php&#8221; from the right side. In the editor &#8211; change the word &#8220;featured&#8221; into your category slug that you want (see below). Save your changes.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/05/change-category.jpg" alt="change category Magazine Style WP Theme   Agency" title="change-category" width="412" height="370" class="alignnone work size-full wp-image-2297" /></p>
<h6>How to insert a Photo Gallery:</h6>
<p>Adding a photo gallery into agency is as easy as pie. Simply go to the post / page you want in &#8220;Edit&#8221; mode and click on the image uploader. Navigate to your local directory and highlight the images you want and click &#8220;Open&#8221;. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/09/insert-gallery.jpg" alt="insert gallery Magazine Style WP Theme   Agency" title="insert gallery" width="412" height="370" class="alignnone work size-full wp-image-2297" /></p>
<p>As soon as the images upload, click on &#8220;Save Changes&#8221; and additional settings will show. Select your options and click &#8220;Insert Gallery&#8221;. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/09/insert-gallery2.jpg" alt="insert gallery2 Magazine Style WP Theme   Agency" title="insert gallery" width="412" height="370" class="alignnone work size-full wp-image-2297" /></p>
<p>Update your post / page and preview it. You should see your gallery in place. The lightbox effect should also automatically pick up. All images that are linked to another image will trigger the lightbox effect in the Agency theme. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/09/screenshot-gallery.jpg" alt="screenshot gallery Magazine Style WP Theme   Agency" title="gallery" width="412" height="370" class="alignnone work size-full wp-image-2297" /></p>
<h6>How to Customize the Navigation Menu:</h6>
<p>Agency supports the WP Menu System which let&#8217;s you customize the links any way you want. Go to &#8220;<strong>Appearance</strong>&#8221; > &#8220;<strong>Menus</strong>&#8221; and start by creating a new menu. Enter a menu name and click &#8220;<strong>Create</strong>&#8220;.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/05/create-menu.jpg" alt="create menu Magazine Style WP Theme   Agency" title="create-menu" width="412" height="370" class="alignnone work size-full wp-image-2301" /></p>
<p>This will create a blank menu panel in the right side of the page. The idea is to select categories, pages or custom links from the left side, click the &#8220;<strong>Add to Menu</strong>&#8221; button &#8211; and it will appear on the menu panel in the right. In this panel, you can drag and drop the links so you can design the menu hierarchy. Links that are staggered underneath become the drop down links from the respective parent &#8211; you get the drift. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/05/menu-system.jpg" alt="menu system Magazine Style WP Theme   Agency" title="menu-system" width="412" height="370" class="alignnone work size-full wp-image-2302" /></p>
<p>Once the menu is done &#8211; hit &#8220;<strong>Save Menu</strong>&#8221; and in the top most left column box called &#8220;<strong>Theme Locations</strong>&#8220;, select the menu you just created from the drop down called &#8220;Header Menu&#8221;. Click &#8220;<strong>Save</strong>&#8221; and view your website. You menu should now be in place.</p>
<h3>Credits:</h3>
<p>The contact form code came from <a href="http://trevordavis.net/blog/wordpress-jquery-contact-form-without-a-plugin">Trevor Davis</a> &#8211; which works like a charm. The lightbox effect for the images are from <a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/documentation/">No Margin for Errors</a>. The Javascript for the floating sidebar is from a plugin called &#8220;<a href="http://plugins.jquery.com/node/8152">stickyfloat</a>&#8220;. Finally, the awesome model photos from the demo site are from my friend <a href="https://www.facebook.com/pages/Photos-by-jigs/110389142352244">Jigs Tambong</a>. </p>
<h3>Conclusion:</h3>
<p>Agency is ideal for high content blogs with multiple post categories. Some HTML and CSS knowledge is required to customize, as well as Photoshop for the graphic elements. On the same note, my recent theme &#8220;<a href="http://fearlessflyer.com/2011/03/looking-for-a-fresh-wordpress-theme-try-lucky-guess/">Lucky Guess</a>&#8221; is now FREE!. Please follow me in <a href="http://twitter.com/_fearlessflyer">Twitter</a>, <a href="http://www.facebook.com/pages/Fearless-Flyer-Design/136158589732362">Facebook</a> or leave your comments below: </p>
<p>You can purchase Agency from this <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&#038;hosted_button_id=2GQ75EJBWU4YJ">link</a></strong>.</p>
<p>BTW, you have to check out BlogEx for a large collection of <a href="http://bloggingexperiment.com/">WordPress Themes</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2011/05/magazine-style-wp-theme-agency/feed/</wfw:commentRss>
		<slash:comments>195</slash:comments>
		</item>
		<item>
		<title>How to Add Lightbox to WordPress without a Plugin</title>
		<link>http://fearlessflyer.com/2011/04/how-to-add-lightbox-to-wp-without-plugin/</link>
		<comments>http://fearlessflyer.com/2011/04/how-to-add-lightbox-to-wp-without-plugin/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 05:26:45 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[creative]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[image effects]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[WP Themes]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2121</guid>
		<description><![CDATA[Many times when I&#8217;m developing themes &#8211; I think of the simplest features to include. Always on top of my list &#8211; is a lightbox effect on images. A lightbox effect is when a thumbnail of an image is clicked, the larger version of the image is faded in &#8211; while the rest of the ]]></description>
			<content:encoded><![CDATA[<p>Many times when I&#8217;m developing themes &#8211; I think of the simplest features to include. Always on top of my list &#8211; is a lightbox effect on images. A lightbox effect is when a thumbnail of an image is clicked, the larger version of the image is faded in &#8211; while the rest of the page is dimmed in the background. This is very useful because it eliminates the need to leave the current page just to view the large version of the image. </p>
<p>Adding it to a WordPress theme has its benefits as well. For one, the code stays with the theme. Anyone who uses it gets this effect automatically. Not to mention, it&#8217;s pretty easy to implement.  </p>
<p>This article will walk you through how to add Lightbox into your WordPress themes. I&#8217;m also going to assume that you have created WordPress themes before, for you will need to know how to work with template files and such. Ready to get started? Let&#8217;s begin. </p>
<h3>Grab Pretty Photo</h3>
<p>There are many lighbox plugins out there. I choose one called Prettyphoto from <a href="http://www.no-margin-for-errors.com/">no-margin-for-errors.com</a>. Prettyphoto uses jQuery, and is quite extensible. But the main reasons why I chose it is because the animation is flawless and the design is awesome. Download the production version from this <a href="http://www.no-margin-for-errors.com/demos/prettyPhoto-jquery-lightbox-clone/prettyPhoto_compressed_3.1.2.zip">link</a></p>
<p>Extract the .zip file into your hard drive. Inside <strong>prettyPhoto_compressed_3.1.2</strong> &#8211; you will find the following folders and files. Copy them according to below:</p>
<ul>
<li><strong>prettyPhoto folder</strong> (from prettyPhoto_compressed_3.1.2\images) and place inside (yourtheme\images\)</li>
<li><strong>prettyPhoto.css</strong> (from prettyPhoto_compressed_3.1.2\css) and place inside your theme root folder</li>
<li><strong>jquery.prettyPhoto.js</strong> (from prettyPhoto_compressed_3.1.2\js) and place inside (yourtheme\scripts\)</li>
</ul>
<h3>Include the Scripts</h3>
<p>First we need jQuery. There is a preferred way to include jQuery into our themes &#8211; that is to use the <strong><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">wp_enqueue_script</a></strong> function. Open <strong>functions.php</strong> and add the code below. *If your theme doesn’t have a functions.php file – go ahead and create one.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> insert_jquery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'insert_jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Note that this is the preferred way because since WordPress is already shipped with a bunch of scripts (including jQuery) &#8211; you might as well use them. It is also considered good practice because updating Worpdress will include these javascript libraries (and how often do you do that!)</p>
<p>Add the Prettyphoto script and css into your theme header.php file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('template_directory'); ?&gt;/prettyPhoto.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; charset=&quot;utf-8&quot; /&gt;
&lt;script src=&quot;&lt;?php bloginfo('template_directory'); ?&gt;/scripts/jquery.prettyPhoto.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Custom Code</h3>
<p>Modify the code in prettyPhoto.css. This step is necessary so the path to the images for prettyPhoto is corrected according to your setup:</p>
<ul>
<li>open <strong>prettyPhoto.css</strong> </li>
<li><strong>CTRL + F</strong> (Find) all instances of “<strong>url(../</strong>”</li>
<li>And replace with “<strong>url(</strong>” *There should be around 100 occurences </li>
<li>Save the file</li>
</ul>
<p>Again, this is due to the location of the images and the css file has changed from the example files from prettyPhoto. This ensures the images needed for our lightbox is functioning properly:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/04/lb1.jpg" alt="lb1 How to Add Lightbox to Wordpress without a Plugin" title="lb1" width="576" height="290" class="alignnone size-full wp-image-2125" /></p>
<p>Open <strong>header.php</strong> – and add the following code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>  
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[href$='.jpg'], a[href$='.jpeg'], a[href$='.gif'], a[href$='.png']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prettyPhoto</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	animationSpeed<span style="color: #339933;">:</span> <span style="color: #3366CC;">'normal'</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">/* fast/slow/normal */</span>
	padding<span style="color: #339933;">:</span> <span style="color: #CC0000;">40</span><span style="color: #339933;">,</span> <span style="color: #009966; font-style: italic;">/* padding for each side of the picture */</span>
        opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.35</span><span style="color: #339933;">,</span> <span style="color: #009966; font-style: italic;">/* Value betwee 0 and 1 */</span>
	showTitle<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #006600; font-style: italic;">/* true/false */</span>			
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>What the above code does is selecting all links with the <strong>href</strong> attribute that equals to anything ending in <em>.jpeg, .jpg, .gif</em> and <em>.png</em>, and applying the <em>prettyPhoto()</em> function to it.  This means that any link tag that leads to an image (file extensions mentioned) will trigger prettyPhoto. The script is also enclosed inside a document ready event using a jQuery noConflict wrapper. This is to prevent any compatibility issues with other javascript libraries that maybe included with your theme. </p>
<p>I also went ahead and added some options such as the animation speed, padding and show title to our .prettyPhoto function. For additional customization options – refer to the <a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/documentation/">no-margin-for-errors documentation</a>.   </p>
<h3>Conclusion</h3>
<p>If all goes well &#8211; you can test your work by clicking on an image that links to another image. This should launch the prettyPhoto code that we&#8217;ve just plugged in. You can also apply the same code to links with inline content, external files, youtube movies or other flash based content. Again, refer to prettyPhoto documentation. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2011/04/how-to-add-lightbox-to-wp-without-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Create an Awesome Photo Gallery with FancyBox and TimThumb</title>
		<link>http://fearlessflyer.com/2011/01/create-an-awesome-photo-gallery-with-fancybox-and-timthumb/</link>
		<comments>http://fearlessflyer.com/2011/01/create-an-awesome-photo-gallery-with-fancybox-and-timthumb/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 16:41:46 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Fancybox]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[Gallery]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[TimThumb]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1978</guid>
		<description><![CDATA[Time for a little tutorial eh? Let’s make a Photo Gallery – one that is a combination of already made scripts and plugins; one that is loaded automatically; and of course – one that looks awesome. We are using PHP, FancyBox jQuery plugin and TimThumb. Important: You should use the latest version of TimThumb due ]]></description>
			<content:encoded><![CDATA[<p>Time for a little tutorial eh? Let’s make a Photo Gallery – one that is a combination of already made scripts and plugins; one that is loaded automatically; and of course – one that looks awesome. We are using PHP, FancyBox jQuery plugin and TimThumb. </p>
<div class="special">Important: You should use the latest version of TimThumb due to vulnerability issues with old code. Make sure you keep updated to keep your site secure.</div>
<p>First, take a look of what we’re making:</p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/photo-gallery/">View Demo</a></div>
<p>Ready to get started? Let’s begin:</p>
<h3>Set up the Environment:</h3>
<p>In order for our PHP scripts to run, you need to have a web server. A good example is XAMPP, which is free and can be downloaded from <a href="http://www.apachefriends.org/en/xampp.html">http://www.apachefriends.org/en/xampp.html</a>.  Create a root folder – name it anything, and inside it, create the following folders:</p>
<ul>
<li><strong>Images </strong> &#8211; this is where the image of the gallery will go. </li>
<li><strong>Scripts </strong> – this is where our scripts will go</li>
</ul>
<p>Download <strong>Timthumb </strong>script: <a href="http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/">http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/</a>. Timthumb is an image resizer script that is written in PHP.  Save <strong>timthumb.php</strong> inside scripts. </p>
<p>Let’s create a new HMTL file inside the root, name it<strong> index.php</strong>. Add this line of code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/root/images/'</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'images/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The above code creates 2 variables: </p>
<ul>
<li><strong>$path</strong> – is the full image path of our images</li>
<li><strong>$files</strong> – is an array of filenames from a specified folder that we’ve scanned through the<strong> scandir()</strong> function</li>
</ul>
<p>Then add the code below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;li &gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&lt;img src=&quot;scripts/timthumb.php?src=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;h=134&amp;w=264&amp;zc=1&amp;q=100&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></td></tr></table></div>

<p>This loops through each item in the array $files – and assign it to another variable $file. For each one found, we’re printing a list item with an anchor and image tags. Within these tags you’ll notice the variables we’ve created earlier. The timthumb script is inserted at the beginning of the src attribute of our thumbnails. The width and the height parameters are hard coded in there as well. Note that we are going to randomize this section a little bit later.</p>
<p>Assuming that you already have photos in your image folder &#8211; fire up your web browser and navigate to index.php. You should have something like the screenshot below:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot1.jpg" alt="screenshot1 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot1" width="576" height="500" class="alignnone size-full wp-image-1979" /></p>
<p>As you can see – we’re swiftly on our way. Our thumbnails are resizing right. Once clicked, the larger image appears. Though there are mysterious images that are returning empty (<em>file name is shows as “.” and “..”</em>). This may not be the case with yours &#8211; but with me, I just decided to fix this by wrapping our list items inside an ‘if &#8211; else’ statement:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'.'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;li &gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&lt;img src=&quot;scripts/timthumb.php?src=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;h=194&amp;w=224&amp;zc=1&amp;q=100&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Now we move on to the Fancy Box script: </p>
<h3>Add Fancy Box</h3>
<p>I almost always use jQuery for all my projects. It is one of the most versatile and powerful javascript libraries to date. Download the latest version from <a href=" http://jquery.com/ "> http://jquery.com/ </a> and include it in your document:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;scripts/jquery-1.4.4.min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>Download the Fancybox files from <a href="http://fancybox.net/">http://fancybox.net/</a>. Once again, include the script right under the jQuery one. Note that Fancy box comes with its own image folder and css file. You need to include that css as well:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;scripts/jquery.fancybox-1.3.1.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;scripts/fancybox/jquery.fancybox-1.3.1.css&quot; /&gt;</pre></td></tr></table></div>

<p>Now let’s add a “<strong>rel</strong>” attribute to our anchor tag, with a value of “<strong>lightbox</strong>”. This makes it easier for our script to target which elements to add an effect on.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;a href=&quot;&lt;?php echo $path . $file; ?&gt; rel=”lightbox” &quot;&gt;…</pre></div></div>

<p>Finally, create a new script tag and add our line of code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[rel=lightbox]&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">'transitionIn'</span>		<span style="color: #339933;">:</span> <span style="color: #3366CC;">'elastic'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'transitionOut'</span>		<span style="color: #339933;">:</span> <span style="color: #3366CC;">'elastic'</span>		
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The above code states that when the document is ready – grab all the anchor tags with an attribute value of “lightbox” and hook it up with the fancybox function. I’ve chosen the effect  ‘Elastic’  for the transitions – you can replace this with your own liking. </p>
<p>Now go back to the browser and hit F5 to refresh. Click on a thumbnail – you should see Fancy Box in action with smooth and eye popping animation added to your photo gallery. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot2.jpg" alt="screenshot2 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot2" width="576" height="500" class="alignnone size-full wp-image-1980" /></p>
<p>Next up – some styling with <strong>CSS</strong>.</p>
<h3>Pretty &#8216;er up.</h3>
<p>Now it is always good practice to separate your formatting and markup. Create a new file named <strong>style.css</strong>, go back to index.php and link the stylesheet as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot;  /&gt;</pre></div></div>

<p>In the last screenshot you notice that I marked the little buttons. That’s because of two things – if you’ve configured Fancybox correctly – those icons should be visible. The other thing is, I’ve created an icon that is very identical to those of Fancybox’s – and we’ll include in our thumbnails.  Take a look at the couple of images below:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot3.jpg" alt="screenshot3 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot3" width="576" height="127" class="alignnone size-full wp-image-1981" /></p>
<p>These images (available in the download) I’ve saved inside the root folder. In your style.css – add these lines of code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">bg.jpg</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
ul li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> 
	<span style="color: #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;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> 
	<span style="color: #00AA00;">&#125;</span>
ul li a img <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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">9px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ffffff</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;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">24px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The code above adds a nice texture to our gallery background. Next, it floats each item to the left – aligning them all side by side. Then it adds a nice white background to each image, along with proper paddings and margins:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot4.jpg" alt="screenshot4 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot4" width="576" height="250" class="alignnone size-full wp-image-1982" /></p>
<p>Remember our custom script tag just above our closing head tag? – add, this line of code just in between the <strong>$(document).ready()</strong> function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span&gt;&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will insert an empty span tag inside each of our list items (this is for the small magnifying glass icon). If you’re thinking – why not just add an inline span tag in our “for each” loop inside index.php – that’s an excellent question. This is because for users  without javascript enabled – they won’t see this magnifying button. </p>
<p>Add these lines of code inside our style.css:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul li span <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">magnify.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">27px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">26px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">290px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-3px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #00AA00;">&#125;</span>
ul li img <span style="color: #00AA00;">&#123;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">7px</span> <span style="color: #cc00cc;">#807a72</span><span style="color: #00AA00;">;</span> 
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">7px</span> <span style="color: #cc00cc;">#807a72</span><span style="color: #00AA00;">;</span> 
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">7px</span> <span style="color: #cc00cc;">#807a72</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> 
	-moz-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span> 
	-webkit-border-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The above styles adds the subtle details that will make our thumbnails beautiful. This includes – of course our magnify.png, CSS3 box shadows (box-shadow) and rounded corners (border-radius). </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot5.jpg" alt="screenshot5 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot5" width="576" height="250" class="alignnone size-full wp-image-1983" /></p>
<p>Our gallery looks really good so far, but not good enough. Let’s add some embellishments. </p>
<h3>Randomize the Images and Orientation:</h3>
<p>Let’s make the thumbnail images be mixed orientation – some tall and some wide. Remember our thumbnail dimensions declared right after the timthumb script? All we need to do is switch the height and width values. So let’s create a PHP function. Append this code on top of index.php (right before the <strong>html</strong> tag):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
	<span style="color: #000000; font-weight: bold;">function</span> random_orientation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>		
		<span style="color: #000088;">$orientation</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;h=194&amp;w=224'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;h=224&amp;w=194'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">shuffle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$orientation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$orientation</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$o</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$o</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>		
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The code above randomizes the two strings (‘<strong>&#038;h=194&#038;w=224</strong>&#8216; and &#8216;<strong>&#038;h=224&#038;w=194</strong>’). Then we call this function where our image tag is:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;img src=&quot;scripts/timthumb.php?src=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> random_orientation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;zc=1&amp;q=100&quot; /&gt;</pre></div></div>

<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot6.jpg" alt="screenshot6 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot6" width="576" height="350" class="alignnone size-full wp-image-1984" /></p>
<p>Now our thumbnails have different orientation each time we refresh. But as you can see, we need to fix the float – some thumbnails get stuck where portrait ends. We also need to fix the magnify icon positioning. </p>
<p>We need a way to tell what the current thumbnail orientation is, and somehow apply a class to that specific list item. This way we can fix the padding and margins accordingly. Add this line of code inside our “else” statement:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'.'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>	
	<span style="color: #666666; font-style: italic;">//this is the new code to be added:</span>
	<span style="color: #000088;">$current_o</span> <span style="color: #339933;">=</span> random_orientation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This grabs the current orientation and assigns it to a variable. Now, inside our li tag – paste this line of code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 	
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_o</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'&amp;h=224&amp;w=194'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'class=&quot;tall&quot;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This adds a class name of “tall” for each list item – if the $current_o variable equals to the portrait dimension. We also need to replace our image thumbnail script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;img src=&quot;scripts/timthumb.php?src=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> random_orientation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;zc=1&amp;q=100&quot; /&gt;</pre></div></div>

<p>to this new code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;img src=&quot;scripts/timthumb.php?src=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$current_o</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;zc=1&amp;q=100&quot; /&gt;</pre></div></div>

<p>Refresh your browser and if we inspect our code – you should see list items with a class of “tall” for images that have 224 x 194 dimensions:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot7.jpg" alt="screenshot7 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot7" width="576" height="200" class="alignnone size-full wp-image-1985" /></p>
<p>Also, add these lines of code to our style.css file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">250px</span><span style="color: #00AA00;">;</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;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li img <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</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>
ul li<span style="color: #6666ff;">.tall</span> img<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li span <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">222px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li<span style="color: #6666ff;">.tall</span> span <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">210px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-6px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The above code overrides the default styling for the list items.<br />
Note that you also have to delete some previous styling for our list items (see the comments in the download). If you’re following this tutorial – I apologize for the replacements. As you see, I’m developing this as I go.</p>
<p>Lastly, add this code inside index.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/root/images/'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'images/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//this is the new code:</span>
<span style="color: #990000;">shuffle</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This will randomize the images. So now we’ve fixed the list items, magnify icon – as well as randomized the images:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot8.jpg" alt="screenshot8 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot8" width="576" height="350" class="alignnone size-full wp-image-1986" /></p>
<h3>Final Touches:</h3>
<p>So our gallery is so done. Except I like to add those final details that make it really good. Let’s add a pre-loader image. This is when you see a “<strong>loading</strong>” message for each thumbnail before they appear. To do this, we go back to jQuery. Inside our document ready event, add this line of code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img, span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">1.0</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3000</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above code delays our images just a tad bit &#8211; just enough to see a preloader image. Save your “<strong>loading.png</strong>” image in the root directory. In your styles.css, add these lines of code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">loading.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>This just sets a background image to our list items. So next time you load the page – you should see our preloaders:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/01/screenshot9.jpg" alt="screenshot9 Create an Awesome Photo Gallery with FancyBox and TimThumb" title="screenshot9" width="576" height="197" class="alignnone size-full wp-image-1987" /></p>
<p>Finally, download the fancy box <strong>mousewheel.js</strong> pack inside your scripts folder and include in your document:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;scripts/jquery.mousewheel-3.0.2.pack.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>You should now be able to view next and previous images once you scroll your mouse wheel. </p>
<h3>Conclusion:</h3>
<p>Well now, I think our gallery is ready for prime time. The good thing about this is you never have to re-size a thumbnail again. All you need to do is add the large image inside the &#8220;images&#8221; folder and presto! Another good thing is that your gallery doesn&#8217;t look the same all the time. With our randomized order and orientation, the gallery looks fresh at each refresh. <strong>So go ahead and grab the <a href="http://fearlessflyer.com/downloads/photo-gallery.zip">download</a> files</strong>. Play around with it &#8211; and maybe even improve the code. Be sure to include your comments below:</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2011/01/create-an-awesome-photo-gallery-with-fancybox-and-timthumb/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Yet Another jQuery Accordion Tutorial</title>
		<link>http://fearlessflyer.com/2010/11/yet-another-jquery-accordion-tutorial/</link>
		<comments>http://fearlessflyer.com/2010/11/yet-another-jquery-accordion-tutorial/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 19:22:15 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1905</guid>
		<description><![CDATA[It just about that time some good old fashioned web programming. Today we’re learning how to create an accordion style page – using my most favorite of tools: jQuery and CSS. We will try to accomplish an accordion that is so simple, yet useful enough for you to use in your existing pages. Ready to ]]></description>
			<content:encoded><![CDATA[<p>It just about that time some good old fashioned web programming. Today we’re learning how to create an accordion style page – using my most favorite of tools: jQuery and CSS. We will try to accomplish an accordion that is so simple, yet useful enough for you to use in your existing pages. Ready to get started – let’s begin.</p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/accordion/">View Demo</a></div>
<h3>The Goal:</h3>
<p>We will use clean markup. We’re trying to integrate this into exsting HTML – so we will be generating all extra classes and tags using Javascript.  I imagine most web documents follow the same constant pattern: Heading tags, followed by some content which are a mixture of different DIVS, paragraphs, images etc. This goes on until the next heading tag &#8211; which is usually the same type as the first heading. </p>
<p>Look at the sample mark up below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;h5&gt;Some Heading&lt;/h5&gt;
       &lt;!--content in here--&gt;
&lt;h5&gt;Some Heading&lt;/h5&gt;
       &lt;!--content in here--&gt;
&lt;h5&gt;Some Heading&lt;/h5&gt;
        &lt;!--content in here--&gt;</pre></td></tr></table></div>

<p>We will use the H5 tags as our “<strong>Clicker</strong>” – once clicked, will hide the contents right underneath it. Click it again, and it will show the contents again. </p>
<h3>The Script:</h3>
<p>We start by calling the jQuery library, followed by the document.ready() call:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.4.3.min.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #339933;">&lt;!--</span>script goes here<span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>We then loop through each of our particular heading tag (in this case, all of H5).  Once it finds all of them, it checks to see if right next to it is another H5 tag; if it’s not, it adds a class of “<strong>clicker</strong>” to it and appends a span with a minus (-) sign in it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>				
	    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;clicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span&gt;-&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
	<span style="color: #009900;">&#125;</span>					
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If you investigate your code so far – you will see that only the H5 tags that have content OTHER than H5 tags have the class “<strong>clicker</strong>” and the span tag with a minus (-) sign in it: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/11/accordion1.jpg" alt="accordion1 Yet Another jQuery Accordion Tutorial" title="accordion1" width="576" height="298" class="alignnone size-full wp-image-1906" /></p>
<p>Now let’s code the click events:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5.clicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>			
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">nextUntil</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'+'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">nextUntil</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>Now that we have our designated clickers, we create a couple of functions that toggle at every click. </p>
<p>The first action, hides the contents below &#8220;<strong>$(this)</strong>&#8221; – which is the tag you just clicked. Remember &#8211; we only want to hide the contents up until the next H5 tag. It also changes the content of the span into a plus (+) symbol.</p>
<p>The second action shows the contents below, and changes the span to a minus (-) symbol. </p>
<h3>Optional Styling:</h3>
<p>At this point you already have a functional accordion. If you’re applying the code to an existing page, you are already working with the current styles.  Although, using CSS3 for say the plus (+) and minus (-) span looks pretty cool – which I’m sure you’d want to use. </p>
<p>Add this code to your styles:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:visited </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;">#2daebf</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">alert-overlay.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">9px</span> <span style="color: #933;">2px</span> <span style="color: #933;">9px</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;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> 
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</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.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</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.5</span><span style="color: #00AA00;">&#41;</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;">-1px</span> <span style="color: #933;">1px</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.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> 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.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</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-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-47px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*ie 7*/</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:hover</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;">#007d9a</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: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:active</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">23px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #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: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-1px</span> <span style="color: #933;">1px</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.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Of course you have to replace the #wrap h5 with your own class / ids. This creates the css3 button you see in the demo. This code is courtesy of <a href="http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba"> Zurb’s Super Awesome buttons with CSS3 and RGBA:</a>   </p>
<h3>Conclusion</h3>
<p>And that is it! You have yourself an accordion page powered by jQuery.  Feel free to grab this code and improve it. Maybe refactor it into a more plugin like code – make it more reusable. Or even &#8211; fix the choppiness issue in the slideUp / slideDown animation in certain browsers. In any case, please leave a comment on what you think of this code.</p>
<p>You might also be interested in these articles regarding jQuery accordions: </p>
<ul>
<li><a href="http://www.sohtanaka.com/web-design/simple-accordion-w-css-and-jquery/">Simple Accordion w/ CSS and jQuery</a></li>
<li><a href="http://net.tutsplus.com/tutorials/javascript-ajax/exactly-how-to-create-a-custom-jquery-accordion/">Exactly How to Create a Custom jQuery Accordion </a></li>
<li><a href="http://css-tricks.com/grid-accordion-with-jquery/">Grid Accordion with jQuery</a></li>
</ul>
<div class="special">There are no downloads for this tutorial because it&#8217;s pretty simple to follow. View the source code of the demo page to get the code</div>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/accordion/">View Demo</a></div>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/11/yet-another-jquery-accordion-tutorial/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Kick Ass Theme built for WP 3: Rotary</title>
		<link>http://fearlessflyer.com/2010/09/free-kick-ass-theme-built-for-wp-3-rotary/</link>
		<comments>http://fearlessflyer.com/2010/09/free-kick-ass-theme-built-for-wp-3-rotary/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 20:59:50 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Wordpress Themes]]></category>
		<category><![CDATA[carousel]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[custom post type]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[roundabout]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress 3.0]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[WP Themes]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1833</guid>
		<description><![CDATA[Oh I spend too much time in front of my pc – my wife always say. This time around – I sat, designed and coded a straight how many hours and am glad to produce: Rotary. Rotary is a two column theme with tons of features including a kicker home page. It is built to ]]></description>
			<content:encoded><![CDATA[<p>Oh I spend too much time in front of my pc – my wife always say. This time around – I sat, designed and coded a straight how many hours and am glad to produce: Rotary. Rotary is a two column theme with tons of features including a kicker home page. It is built to be used with WordPress 3.0, and is centered around the idea of running your blog as a CMS. Let me explain:</p>
<table>
<tr>
<td>
<div class="viewdemo"><a href="http://rotary.fearlessflyer.com/">View the Demo</a></div>
</td>
<td style="padding-left:10px;">
<div class="buylink"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&#038;hosted_button_id=AVY4TURWUQ2CN">Buy in Paypal</a></div>
</td>
</tr>
</table>
<p>Below is a screenshot of Rotary&#8217;s glorious homepage. The roundabout carousel sits right on the fold &#8211; with images that are pulled straight from your post thumbnails. Click to view the Rotary Demo page: </p>
<p><a href="http://rotary.fearlessflyer.com/"><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/09/rotary22.jpg" alt="rotary22 Kick Ass Theme built for WP 3: Rotary" title="rotary2" width="576" height="639" class="alignnone size-full wp-image-2247" /></a></p>
<h3>Custom Post Type</h3>
<p>You like that carousel / slider in the home page? Well that is due to the amazing code known as the <strong><a href="http://fredhq.com/projects/roundabout/">roundabout by Fred LeBlanc</a></strong>. You can easily change the contents of this carousel in two ways: </p>
<h6>1) Using a custom post type</h6>
<p>In the left hand side of the admin area you will notice a section called “<strong>Roundabouts</strong>”. Simply add a new roundabout and give it a title, some content and attach a “<em>feature image</em>”.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/09/rotary2.jpg" alt="rotary2 Kick Ass Theme built for WP 3: Rotary" title="rotary2" width="576" height="483" class="alignnone size-full wp-image-1837" /></p>
<p>The images are automatically resized to the right dimensions. Also &#8211; you’re only allowed up to 5 roundabouts. </p>
<h6>2) Change the static code </h6>
<p>If you decide you don’t want to use the custom post type feature – you can simply change the HTML. Inside home.php you will see  an unordered list with each item as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/images/586x360.jpg&quot; alt=&quot;Need Image Here&quot; /&gt;&lt;/a&gt;&lt;div class=&quot;hiddendesc&quot;&gt;Need to Enter Image&lt;/div&gt;&lt;/li&gt;</pre></td></tr></table></div>

<p>Simply replace the values of your images, title and link and you’re set to go. </p>
<h3>The Navigation Menu</h3>
<p>This by far is my favorite 3.0 feature – custom menus. It&#8217;s simply amazing. I’ve added the code to Rotary that lets you design the main navigation of the theme. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/09/rotary3.jpg" alt="rotary3 Kick Ass Theme built for WP 3: Rotary" title="rotary3" width="576" height="500" class="alignnone size-full wp-image-1838" /></p>
<p>Simply drag and drop items to the menu builder and save. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/09/rotary4.jpg" alt="rotary4 Kick Ass Theme built for WP 3: Rotary" title="rotary4" width="576" height="175" class="alignnone size-full wp-image-1839" /></p>
<h3>Feature Images</h3>
<p>Just like the roundabout items – all posts in this theme can have its own feature image. Simply use the “<em>Set feature Image</em>” option for each post: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/09/rotary5.jpg" alt="rotary5 Kick Ass Theme built for WP 3: Rotary" title="rotary5" width="576" height="550" class="alignnone size-full wp-image-1840" /></p>
<p>This image will show as thumbnails in the archive pages, and a medium photo inside the single page template:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/09/rotary6.jpg" alt="rotary6 Kick Ass Theme built for WP 3: Rotary" title="rotary6" width="576" height="350" class="alignnone size-full wp-image-1835" /></p>
<h3>Conclusion</h3>
<p>Truly by using the features above – you can utilize the power of WordPress 3.0 as well as turn your blog into a cool CMS.  Give Rotary a spin – it’s cool, it works and it’s only $10! Please leave your questions and comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/09/free-kick-ass-theme-built-for-wp-3-rotary/feed/</wfw:commentRss>
		<slash:comments>116</slash:comments>
		</item>
		<item>
		<title>How to Create Your Own jQuery Content Slider</title>
		<link>http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/</link>
		<comments>http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 19:27:47 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Content Slider]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1762</guid>
		<description><![CDATA[This tutorial will show you how to create your own jQuery content slider. You may ask &#8220;Why create my own if there are hundreds of already made sliders out there?&#8221; This is true: I myself almost always use ready made plugins for my projects. Yet, it is always a good thing to know how they ]]></description>
			<content:encoded><![CDATA[<p>This tutorial will show you how to create your own jQuery content slider. You may ask &#8220;<em>Why create my own if there are hundreds of already made sliders out there?</em>&#8221; This is true: I myself almost <em>always</em> use ready made plugins for my projects. Yet, it is always a good thing to know how they work. It also comes in handy &#8211; if you should ever want to customize it (it’s always harder to edit someone else’s code). </p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/content-slider/">View the Demo</a></div>
<div class="special">If you choose to skip the tutorial &#8211; you are free to download the source code from this <a href="http://fearlessflyer.com/downloads/content-slider.zip">link</a></div>
<p>So are you ready to get started? Let’s begin: </p>
<h3>Step 1: Create the Base Mark Up</h3>
<p>What we need is a series of images in an unordered list:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
&lt;li&gt;&lt;img src=&quot;image1.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image2.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image3.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image4.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image6.jpg&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Pretty straightforward code – view it in the browser and see a bunch of images listed from top to bottom. </p>
<h3>Step 2: Add jQuery Code to hide unfocused images:</h3>
<p>What we’re trying to achieve is to only show the first image of the list and hide the rest. We do this by applying some CSS rules via jQuery to the mark up we&#8217;ve created. We also want to line up the hidden images to the right – so we can add controls that animate the entire ul a little bit to the left at a time (see illustration below):</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot1.jpg" alt="screenshot1 How to Create Your Own jQuery Content Slider" title="screenshot1" width="576" height="490" class="alignnone size-full wp-image-1763" style="border:none;" /></p>
<p>Add the following code right above the closing head tag:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> theImage <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul li img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> theWidth <span style="color: #339933;">=</span> theImage.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #006600; font-style: italic;">//wrap into mother div</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wrap</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;mother&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>					
	<span style="color: #006600; font-style: italic;">//assign height width and overflow hidden to mother</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mother'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		width<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> theWidth<span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
		height<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> theImage.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
		position<span style="color: #339933;">:</span> <span style="color: #3366CC;">'relative'</span><span style="color: #339933;">,</span>
		overflow<span style="color: #339933;">:</span> <span style="color: #3366CC;">'hidden'</span>  	
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//get total of image sizes and set as width for ul </span>
	<span style="color: #003366; font-weight: bold;">var</span> totalWidth <span style="color: #339933;">=</span> theImage.<span style="color: #660066;">length</span> <span style="color: #339933;">*</span> theWidth<span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		width<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> totalWidth<span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>				
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//doc ready</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>In English</strong>: in the first script tag – we have connected to the jQuery library online. Then we go in the <strong>window.load()</strong> event *as supposed to document.ready() – because of an <a href="http://stackoverflow.com/questions/1126272/are-image-properties-part-of-the-dom-jquery-webkit-inconsistency-with-other-br">issue detecting image width and height with webkit browsers</a>. Then we set up a couple of variables which are all the images inside the unordered list, along with their widths. We wrap the unordered list (using the .wrap() function) inside a div called “mother” with the CSS rules I mentioned.</p>
<h3>Step 3: Add “Next” and “Previous” Buttons</h3>
<p>In our HTML – add anchor tags with the class “<em>next</em>” (If you want to move forward the slider) and “<em>previous</em>” (to go backward) inside the list items:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
&lt;li&gt;&lt;img src=&quot;image1.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image2.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image3.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image4.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image6.jpg&quot; /&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;a class=&quot;startover&quot; href=&quot;#&quot;&gt;startover&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Note that you will not see these links when you preview the page. This is because they are tucked away outside the visible region of the overflow property we’ve created: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot2.jpg" alt="screenshot2 How to Create Your Own jQuery Content Slider" title="screenshot2" width="576" height="396" class="alignnone size-full wp-image-1764" style="border:none;" /></p>
<h3>Step 3: The Nifty .Animate()Method</h3>
<p>Okay, now we’ve come to the part where we actually see some action. The whole point of what we’re trying to do is to move the list a little to the right – when the &#8220;<em>next</em>&#8221; link is clicked, and to the left if &#8220;<em>previous</em>&#8221; is clicked: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot3.jpg" alt="screenshot3 How to Create Your Own jQuery Content Slider" title="screenshot3" width="576" height="396" class="alignnone size-full wp-image-1765" style="border:none;" /></p>
<p>Add the following javascript code inside the existing script tags:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>theImage<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>		
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>intIndex<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>				
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">nextAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.next&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>	<span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #3366CC;">&quot;margin-left&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>intIndex <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> theWidth<span style="color: #009900;">&#41;</span>				
					<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span>	
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.previous&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #3366CC;">&quot;margin-left&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>intIndex <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> theWidth<span style="color: #009900;">&#41;</span>				
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span>	
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.startover&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #3366CC;">&quot;margin-left&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>				
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//close .bind()									 </span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//close .each()</span></pre></td></tr></table></div>

<p><strong>Explanation:</strong> the code above starts out with the “<em>.each</em>” function – which is essentially a loop that looks for each of our images in the list. Then it finds all of the anchor tags next to the images (through <em>.nextAll</em>) and checks them for the assigned class. If the class says <em>“next”</em> – animate the parent (ul) to the left by applying a margin-left CSS property to it. The same thing goes for class<em> “previous”</em>. The only difference is the index is advanced vs. deducted multiplied by the image width. Lastly – is class “<em>startover</em>” which resets the slider to its original position. </p>
<p>Add the CSS code below inside the <em>“head”</em> tag so you can see the links and start testing them:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
<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>
ul <span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span>
ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span> <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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span><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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.startover</span><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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div>

<h3>
Step 4: Make ‘er Nice and Purrty</h3>
<p>Technically – our slider is done. This section mainly focuses on making it look nice and presentable. So I grab this file: <a href="http://fearlessflyer.com/u/slider-constructor">Slider Constructor from Graphic River</a>. Slider Constructor is a high quality Photoshop filled with shiny slider buttons and controls that will surely bring life to your new slider. Create the buttons of your choice from this file and save them as individual .pngs.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot4.jpg" alt="screenshot4 How to Create Your Own jQuery Content Slider" title="screenshot4" width="576" height="178" class="alignnone size-full wp-image-1766" style="border:none;" /></p>
<p>You can set a different button for each anchor tag in each slide. You can also place them anywhere you want with some CSS positioning. Either add an &#8220;id&#8221; attribute to the individual anchor tags, or an additional class (which is what I did). Below is the CSS for my demo &#8211; of course, you might want to code yours differently:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul li a<span style="color: #6666ff;">.next</span>.<span style="color: #993333;">red</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-red.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">57px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">73px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">237px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span>.<span style="color: #993333;">green</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-green.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">286px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">486px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span>.<span style="color: #993333;">green</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">prev-green.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">286px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span><span style="color: #6666ff;">.orange</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-orange.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">239px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">62px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">360px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span><span style="color: #6666ff;">.orange</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">prev-orange.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">239px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">62px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-blue.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">57px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">129px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">562px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">prev-blue.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">58px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">129px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">150px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span>.<span style="color: #993333;">silver</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">previous-silver.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">49px</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;">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;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">305px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">360px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.startover</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">startover.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">176px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">73px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">280px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">420px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Also &#8211; the good thing about this code is you can place and style the buttons individually. </p>
<h3>Conclusion</h3>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/content-slider/">View the Demo</a></div>
<p>There, there – you’ve just done yourself some good coding <em>Sparky</em>!  Feel free to modify, re-factor and make the code better. This is as basic as it gets – so have fun tweaking it. Make sure you leave a comment or spread the word by retweeting or liking it in facebook. Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Pretty Hover Effects with CSS and jQuery</title>
		<link>http://fearlessflyer.com/2010/06/pretty-hover-effects-with-css-and-jquery/</link>
		<comments>http://fearlessflyer.com/2010/06/pretty-hover-effects-with-css-and-jquery/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 01:14:17 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1509</guid>
		<description><![CDATA[This article will show you how to create pretty hover effects for your images using jQuery and CSS. The plan is to use a clean mark up, adding the necessary elements on the fly. What this means is that we are starting from barebones image HTML tags, with title attributes only. This can come useful ]]></description>
			<content:encoded><![CDATA[<p>This article will show you how to create pretty hover effects for your images using jQuery and CSS. The plan is to use a clean mark up, adding the necessary elements on the fly. What this means is that we are starting from barebones image HTML tags, with title attributes only.  This can come useful especially if you already have hundreds of images that you want to apply this effect on. </p>
<div class="viewdemo">
<a href="http://demo.fearlessflyer.com/html/demo/pretty-hovers/">View the Demo:</a>
</div>
<div class="special">
Or Download the source files from <a href="http://fearlessflyer.com/downloads/Pretty-Hovers.zip">Here.</a> Also, feel free to browse the rest of my <a href="http://fearlessflyer.com/downloads/">downloadable stuff</a>
</div>
<p>Take a look at our markup:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
&lt;li&gt;&lt;img src=&quot;images/77335_4871.jpg&quot; title=&quot;Autumn Leaves&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;images/107023_5283.jpg&quot; title=&quot;Cloudy Skies&quot;  /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;images/1282015_12556521.jpg&quot; title=&quot;Nice Horsy&quot;  /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;images/1262387_19591724.jpg&quot;  title=&quot;Grassy Meadows&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;images/220121_3233.jpg&quot; title=&quot;Jigsaw Pieces&quot;  /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;images/1282209_96954111.jpg&quot; title=&quot;Retro Groove&quot;  /&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Pretty clean right? Ok, now we start manipulating and styling with code:</p>
<h3>Step 1: Wrapping Elements with jQuery</h3>
<p>We are going to use jQuery to find all these images in a list item and check if it has a title attribute. If it does, it will wrap the image in a DIV with class name “<em>wrapper</em>”.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>									
		<span style="color: #003366; font-weight: bold;">var</span> thumbs <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul li img&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
		<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> ii <span style="color: #339933;">=</span> thumbs.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> ii<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>thumbs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">title</span> <span style="color: #339933;">&amp;&amp;</span> thumbs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">title</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>								
				$<span style="color: #009900;">&#40;</span>thumbs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wrap</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div class=&quot;wrapper&quot; /&gt;'</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>jQuery will also take the contents of the image’s title and place it inside another DIV called “<em>caption</em>” and place it inside <strong>wrapper</strong>, right after the image itself. Finally, let&#8217;s remove the title attribute from the image tag.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> imgtitle <span style="color: #339933;">=</span> thumbs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">title</span><span style="color: #339933;">;</span>	
after<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div class=<span style="color: #000099; font-weight: bold;">\'</span>caption<span style="color: #000099; font-weight: bold;">\'</span>&gt;'</span> <span style="color: #339933;">+</span> imgtitle <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span>.
				<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>					
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now take a look at our mark up when the document loads:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
&lt;li&gt;
&lt;div class=”wrapper”&gt;&lt;img src=&quot;images/77335_4871.jpg&quot; /&gt;&lt;/div&gt;
&lt;div class=”caption”&gt; Autumn Leaves&lt;/a&gt;
&lt;/li&gt;
...
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Pretty slick right? Now let&#8217;s move forward.</p>
<h3>Step 2: General Styling with CSS</h3>
<p>Now that we have our DIVs in place, we can now set up the general styles with our stylesheet. What we’re trying to achieve is to hide the caption from a viewing area set on its containing DIV: wrapper. </p>
<p>Take a look at our stylesheet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.wrapper</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;">218px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">218px</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;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>  <span style="color: #00AA00;">&#125;</span>
div<span style="color: #6666ff;">.caption</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">55px</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Note that the wrapper dimensions are taken from how wide and tall the images are.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/06/pretty-hovers1.jpg" style="border:none" title="Pretty Hover Effects with CSS and jQuery photo" alt="pretty hovers1 Pretty Hover Effects with CSS and jQuery" /></p>
<h3>Step 3: Events and More Styling with jQuery </h3>
<p>Now back to our script, all we need to do now is assign a couple of events to the hover method of our wrapper DIV.  Thankfully, jQuery’s <strong>.hover()</strong> simplifies this action by letting us bind two handlers (in and out) all within the same context. </p>
<p>All we need to achieve is a way to slide the caption DIV upwards when we hover (maybe decrease the opacity of the image), then slide the DIV back downwards when we mouse out:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.wrapper'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;.6&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.caption'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>top<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;-85px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1.0&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>					
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.caption'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>top<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;85px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>		
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Notice that I also used the <strong>.animate()</strong> function for manipulating the CSS properties which renders all of our effects smoothly. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/06/pretty-hovers2.jpg" style="border:none;" title="Pretty Hover Effects with CSS and jQuery photo" alt="pretty hovers2 Pretty Hover Effects with CSS and jQuery" /></p>
<h3> Optional Pretty Styling:</h3>
<p>For demonstration purposes I’ve added pretty backgrounds, as well as font types to maximize the effect. Simply add a background to the DIV caption, and assign different font types and styles (check out <a href="http://code.google.com/webfonts">Google Fonts</a>). </p>
<p>There you have it. You have just created your own image hover effects using jQuery and CSS. You can download the source code from <a href="http://fearlessflyer.com/downloads/Pretty-Hovers.zip">here</a>, or <a href="http://demo.fearlessflyer.com/html/demo/pretty-hovers/">view the live demo</a>. </p>
<p>Please feel free to comment below on what you think of this tutorial. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/06/pretty-hover-effects-with-css-and-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: fearlessflyer.com @ 2012-02-03 18:40:59 by W3 Total Cache -->
