<?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>Blog and Web Design Portfolio of Adrian Pelletier &#187; jQuery</title>
	<atom:link href="http://www.adrianpelletier.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adrianpelletier.com</link>
	<description></description>
	<lastBuildDate>Thu, 15 Dec 2011 23:30:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Create a Realistic Hover Effect With jQuery</title>
		<link>http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/</link>
		<comments>http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 00:40:32 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.adrianpelletier.com/?p=1047</guid>
		<description><![CDATA[For one of the projects I&#8217;m currently working on with Rareview, we wanted to add a rising hover effect to a set of icon links. Using jQuery&#8217;s animate effect, I ...]]></description>
			<content:encoded><![CDATA[<p><span class="drop_cap">F</span>or one of the projects I&#8217;m currently working on with <a title="Visit Rareview's website" href="http://www.rareview.com/" target="_blank">Rareview</a>, we wanted to add a rising hover effect to a set of icon links. Using <a href="http://jquery.com/" target="_blank">jQuery&#8217;s</a> animate effect, I experimented with icons that have reflections and others with shadows. Here is a demo with two examples:</p>
<p><a class="img-link" title="View the Demo" href="http://adrianpelletier.com/sandbox/jquery_hover_nav/"><img class="alignnone size-full wp-image-1108" src="http://www.adrianpelletier.com/wp-content/uploads/2009/05/jquery-rising-hover-3.jpg" alt="jquery-rising-hover-2" width="438" height="150" /></a></p>
<p>The HTML and CSS are both straightforward and have a structure and style common to many web navigations and menus (for the sake of post length, I&#8217;m not including HTML/CSS code examples here but you are free to snoop around in the demo or view the files in the download below).</p>
<p>In a nutshell, the JS appends the reflection/shadow to each <code>&lt;li&gt;</code>, then animates the position and opacity of these elements and the icon links on hover. I&#8217;ve added <code>.stop()</code> to eliminate any queue buildup from quickly mousing back and forth over the navigation.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Begin jQuery</span>
&nbsp;
$<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: #006600; font-style: italic;">/* =Reflection Nav
-------------------------------------------------------------------------- */</span>	
&nbsp;
    <span style="color: #006600; font-style: italic;">// Append span to each LI to add reflection</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#nav-reflection 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;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
    <span style="color: #006600; font-style: italic;">// Animate buttons, move reflection and fade</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#nav-reflection a&quot;</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: #000066;">stop</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-10px&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">200</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;18px&quot;</span><span style="color: #339933;">,</span> opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.25</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">200</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: #000066;">stop</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0px&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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1px&quot;</span><span style="color: #339933;">,</span> opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/* =Shadow Nav
-------------------------------------------------------------------------- */</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Append shadow image to each LI</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#nav-shadow 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;img class=&quot;shadow&quot; src=&quot;images/icons-shadow.jpg&quot; alt=&quot;&quot; width=&quot;81&quot; height=&quot;27&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Animate buttons, shrink and fade shadow</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#nav-shadow li&quot;</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: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-14px&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">250</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>e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-10px&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">250</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>
        $<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img.shadow&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</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> width<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;80%&quot;</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;20px&quot;</span><span style="color: #339933;">,</span> marginLeft<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;8px&quot;</span><span style="color: #339933;">,</span> opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.25</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">250</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: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4px&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">250</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>e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</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> marginTop<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0px&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">250</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>
        $<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img.shadow&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</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> width<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100%&quot;</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;27px&quot;</span><span style="color: #339933;">,</span> marginLeft<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0px&quot;</span><span style="color: #339933;">,</span> opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// End jQuery</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Please note, for the purposes of this quick demo, I did not bother including support for IE6.</p>
<p><a class="grey_button" title="Check out the demo" href="http://adrianpelletier.com/sandbox/jquery_hover_nav/">View Demo</a> <em> or </em> <a class="grey_button" title="Download the demo" href="http://adrianpelletier.com/sandbox/jquery_hover_nav/demo.zip">Download</a></p>
<p><strong>Update 06/01/2009:</strong> I updated the shadow example so that it has more of a bounce to it.</p>
<p><strong>Update 07/08/2009:</strong> As <a href="http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/comment-page-1/#comment-3367">Cody Lindley</a> points out in the comments (thanks!), this example does not require the UI and could work with jQuery alone (I&#8217;ve updated the link in the post). However, this being a navigation example, I&#8217;ll leave the UI script in the demo and download for users who want to experiment with <a href="http://jqueryui.com/demos/animate/" target="_blank">animating text, background, borders, or outline colors</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/feed/</wfw:commentRss>
		<slash:comments>193</slash:comments>
		</item>
	</channel>
</rss>

