<?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>bavotasan.com &#187; hover</title>
	<atom:link href="http://bavotasan.com/tag/hover/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +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>Amazing Hover Effects with CSS3</title>
		<link>http://bavotasan.com/2011/amazing-hover-effects-with-css3/</link>
		<comments>http://bavotasan.com/2011/amazing-hover-effects-with-css3/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 17:34:46 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[hover effect]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Stylesheet]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3081</guid>
		<description><![CDATA[I have received a lot of questions lately about hover effects and how you can execute them using only CSS. There was a time when you would have to use jQuery to really make your effect stand out, but now CSS3 has some pretty amazing properties that help designers create some lightweight effects that truly [...]]]></description>
			<content:encoded><![CDATA[<p>I have received a lot of questions lately about hover effects and how you can execute them using only CSS. There was a time when you would have to use jQuery to really make your effect stand out, but now CSS3 has some pretty amazing properties that help designers create some lightweight effects that truly stand out.</p>
<h3>Box Shadow</h3>
<p>This effect will create a shadow around your div container when you hover over it:</p>
<p><strong>CSS:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.shadow</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">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;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #6666ff;">.shadow</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</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;">5px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.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: #cc66cc;">0</span> <span style="color: #933;">5px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</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;">5px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><strong>HTML:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;shadow&quot;</span><span style="color: #339933;">&gt;</span>
Ut vulputate sem venenatis magna commodo ac semper nibh mollis<span style="color: #339933;">.</span> Pellentesque suscipit metus non lacus lacinia sed porttitor metus suscipit<span style="color: #339933;">.</span> Aenean egestas augue vel sem tincidunt scelerisque<span style="color: #339933;">.</span> Sed ullamcorper convallis arcu<span style="color: #339933;">,</span> vel euismod urna egestas in<span style="color: #339933;">.</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p><strong>DEMO: </strong></p>
<div class="shadow">
Ut vulputate sem venenatis magna commodo ac semper nibh mollis. Pellentesque suscipit metus non lacus lacinia sed porttitor metus suscipit. Aenean egestas augue vel sem tincidunt scelerisque. Sed ullamcorper convallis arcu, vel euismod urna egestas in.
</div>
<p>That one&#8217;s pretty simple and straightforward, but still kind of cool. It can also be used on images.</p>
<h3>Opacity</h3>
<p>Having something fade in on a hover can be seen almost anywhere on the web.</p>
<p><strong>CSS:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">img<span style="color: #6666ff;">.opacity</span> <span style="color: #00AA00;">&#123;</span>
	opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.5</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;">50</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>	
&nbsp;
img<span style="color: #6666ff;">.opacity</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</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;">100</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><strong>HTML:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/wp-content/uploads/2011/01/spiral.jpg&quot;</span> width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;550&quot;</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;366&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;opacity&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></td></tr></table></div>

<p><strong>DEMO:</strong></p>
<p><img src="http://bavotasan.com/wp-content/uploads/2011/01/spiral.jpg" width="550" height="366" alt="" class="opacity" /></p>
<p>If you want to create an even cooler opacity fade effect, you can take advantage of the new transition property. Note, this will only work in Webkit browsers such as Chrome and Safari.</p>
<p><strong>CSS:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">img<span style="color: #6666ff;">.opacity</span> <span style="color: #00AA00;">&#123;</span>
	opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.5</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;">50</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
 	-webkit-transition<span style="color: #00AA00;">:</span> opacity 1s linear<span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>	
&nbsp;
img<span style="color: #6666ff;">.opacity</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</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;">100</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
 	-webkit-transition<span style="color: #00AA00;">:</span> opacity 1s linear<span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><strong>DEMO:</strong></p>
<p><img src="http://bavotasan.com/wp-content/uploads/2011/01/spiral.jpg" width="550" height="366" alt="" class="opacitywk" /></p>
<p><small>(this one only works in Chrome or Safari)</small></p>
<h3>The Switch and/or Reveal</h3>
<p>I have seen a lot of sites use an effect where something is revealed when you hover over an element. This one needs a bit more CSS and HTML since it requires two elements that sit on top of one another. I&#8217;m using text and an image in the example below but it can be two images, links or anything you want. Just remember that both elements need to use absolute positions or the effect will not work properly.</p>
<p><strong>CSS:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">div.<span style="color: #000000; font-weight: bold;">top</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">120px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#aaa</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: #00AA00;">&#125;</span>	
&nbsp;
	div.<span style="color: #000000; font-weight: bold;">top</span> div <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">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;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">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: #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;">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;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span>
&nbsp;
	div.<span style="color: #000000; font-weight: bold;">top</span> div<span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</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>		
&nbsp;
div.<span style="color: #000000; font-weight: bold;">top</span><span style="color: #3333ff;">:hover </span>div<span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><strong>HTML:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;top&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;first&quot;</span><span style="color: #339933;">&gt;</span>Hover over me to see something happen<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;second&quot;</span><span style="color: #339933;">&gt;&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/wp-content/uploads/2011/01/happyface.jpg&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50&quot;</span> width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p><strong>DEMO:</strong></p>
<div class="top">
<div class="first">Hover over me to see something happen</div>
<div class="second"><img src="http://bavotasan.com/wp-content/uploads/2011/01/happyface.jpg" alt="" height="50" width="50" /></div>
</div>
<p>The above example doesn&#8217;t use CSS3 since it is just taking advantage of the display property. Let&#8217;s see how CSS3 can make this effect stand out.</p>
<p><strong>CSS:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">div.<span style="color: #000000; font-weight: bold;">top</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">120px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#aaa</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: #00AA00;">&#125;</span>	
&nbsp;
	div.<span style="color: #000000; font-weight: bold;">top</span> div <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">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;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">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: #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;">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;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
   		-webkit-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span> 1s ease-in-out<span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span>
&nbsp;
	div.<span style="color: #000000; font-weight: bold;">top</span> div<span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</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>		
&nbsp;
div.<span style="color: #000000; font-weight: bold;">top</span><span style="color: #3333ff;">:hover </span>div<span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span> 1s ease-in-out<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-122px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><strong>DEMO:</strong></p>
<div class="top rv">
<div class="first">Hover over me to see something happen</div>
<div class="second"><img src="http://bavotasan.com/wp-content/uploads/2011/01/happyface.jpg" alt="" height="50" width="50" /></div>
</div>
<p><small>(this one also only works in Chrome or Safari)</small></p>
<p>You can have the slide work in any direction by either use the top property with a positive or negative number, or switching up the left property to use a positive number.</p>
<h3>Position</h3>
<p>A very simple effect that is often used on lists is to have the item slide over as your hover.</p>
<p><strong>CSS:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">ul<span style="color: #6666ff;">.slide</span> li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><strong>HTML:</strong></p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>ul <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;slide&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/downloads/my-first-vanilla-plugin/&quot;</span><span style="color: #339933;">&gt;</span>My First Vanilla Plugin<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/downloads/delete-duplicate-posts-pro-wordpress-plugin/&quot;</span><span style="color: #339933;">&gt;</span>Delete Duplicate Posts Pro WordPress Plugin<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/downloads/feed-me-seymour-free-wordpress-theme/&quot;</span><span style="color: #339933;">&gt;</span>Feed Me<span style="color: #339933;">,</span> Seymour <span style="color:#800080;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/&quot;</span><span style="color: #339933;">&gt;</span>Magazine Basic v2<span style="color: #339933;">.</span>6 WordPress Theme<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://bavotasan.com/downloads/sliderota-jquery-plugin/&quot;</span><span style="color: #339933;">&gt;</span>Sliderota jQuery Plugin<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p><strong>DEMO:</strong></p>
<ul class="slide">
<li><a href="http://bavotasan.com/downloads/my-first-vanilla-plugin/">My First Vanilla Plugin</a></li>
<li><a href="http://bavotasan.com/downloads/delete-duplicate-posts-pro-wordpress-plugin/">Delete Duplicate Posts Pro WordPress Plugin</a></li>
<li><a href="http://bavotasan.com/downloads/feed-me-seymour-free-wordpress-theme/">Feed Me, Seymour 1.2</a></li>
<li><a href="http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/">Magazine Basic v2.6 WordPress Theme</a></li>
<li><a href="http://bavotasan.com/downloads/sliderota-jquery-plugin/">Sliderota jQuery Plugin</a></li>
</ul>
<p>Now let&#8217;s add some CSS3.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">ul<span style="color: #6666ff;">.slide</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	-webkit-transition<span style="color: #00AA00;">:</span> all 0.5s ease-in-out<span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul<span style="color: #6666ff;">.slide</span> li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-webkit-transition<span style="color: #00AA00;">:</span> all 0.5s ease-in-out<span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<ul class="slide pl">
<li><a href="http://bavotasan.com/downloads/my-first-vanilla-plugin/">My First Vanilla Plugin</a></li>
<li><a href="http://bavotasan.com/downloads/delete-duplicate-posts-pro-wordpress-plugin/">Delete Duplicate Posts Pro WordPress Plugin</a></li>
<li><a href="http://bavotasan.com/downloads/feed-me-seymour-free-wordpress-theme/">Feed Me, Seymour 1.2</a></li>
<li><a href="http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/">Magazine Basic v2.6 WordPress Theme</a></li>
<li><a href="http://bavotasan.com/downloads/sliderota-jquery-plugin/">Sliderota jQuery Plugin</a></li>
</ul>
<p><small>(once again this only works in Chrome or Safari)</small></p>
<p>Sadly, not all browsers are up to snuff in regards to CSS3, but as time passes most will release updates that take advantage of all the new properties and effects that have been released.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/amazing-hover-effects-with-css3/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Using jQuery for a Simple Animated Fade Effect</title>
		<link>http://bavotasan.com/2010/jquery-simple-animated-fade-effect/</link>
		<comments>http://bavotasan.com/2010/jquery-simple-animated-fade-effect/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:57:26 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[person]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1817</guid>
		<description><![CDATA[I know I have already done a fade effect between two images with jQuery, but here is a quick little piece of code that will just add a nice animated fade effect to single images. Whenever a person hovers over an image, we will use jQuery to lower the opacity to make it appear lighter. [...]]]></description>
			<content:encoded><![CDATA[<p>I know I have already done a fade effect between two images with jQuery, but here is a quick little piece of code that will just add a nice animated fade effect to single images. Whenever a person hovers over an image, we will use jQuery to lower the opacity to make it appear lighter. Easy and not that impressive but still pretty cool.<br />
<span id="more-1817"></span><br />
Make sure you first call jQuery.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div 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;">'text/javascript'</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">'jquery.js'</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Then just add the following code and all your images will have a slight fade when you hover over them.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div 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>
  $<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;img&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>opacity<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;0.8&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</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>opacity<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</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;">&#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></div></td></tr></table></div>

<p>If you only want this to occur on certain images than just make sure to change the first jQuery selector to the class name of the images your want this effect to affect.</p>
<p>Try it out below:</p>
<p><script type="text/javascript">
  jQuery(document).ready(function(){
    jQuery("img.opacity").hover(function() {
      jQuery(this).stop().animate({opacity: "0.8"}, 'slow');
    },
    function() {
      jQuery(this).stop().animate({opacity: "1"}, 'slow');
    });
  });
</script></p>
<p><img src="http://bavotasan.com/wp-content/uploads/2009/09/jquerylogo.png" alt="" title="" width="200" height="150" class="alignleft opacity" /><img src="http://bavotasan.com/wp-content/uploads/2009/07/jquery.png" title="" alt="" width="200" height="150" class="alignleft opacity" /></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/jquery-simple-animated-fade-effect/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Using jQuery to make an Expandable Code Box for WP-Syntax</title>
		<link>http://bavotasan.com/2009/using-jquery-to-make-an-expandable-code-box-for-wp-syntax/</link>
		<comments>http://bavotasan.com/2009/using-jquery-to-make-an-expandable-code-box-for-wp-syntax/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 17:43:00 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[background color]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[box]]></category>
		<category><![CDATA[Chris Coyier]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[fan]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[highlighter]]></category>
		<category><![CDATA[horizontal]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[minor changes]]></category>
		<category><![CDATA[overflow]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Plugin Code]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[Syntax Highlighter]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[Width]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress plugin]]></category>
		<category><![CDATA[Wp]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1440</guid>
		<description><![CDATA[You may have noticed that I&#8217;m using a new syntax highlighter for my code snippets. I installed Ryan McGeary&#8216;s WordPress plugin WP-Syntax which uses GeSHi (Generic Syntax Highlighter), a simple highlighting class that supports multiple coding languages. It&#8217;s great but I&#8217;m not a fan of the horizontal scrollbar that appears if code extends past your [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bavotasan.com/wp-content/uploads/2009/07/jquery.png" alt="jquery" title="jquery" width="200" height="150" class="alignright size-full wp-image-726" />You may have noticed that I&#8217;m using a new syntax highlighter for my code snippets. I installed <a href="http://ryan.mcgeary.org/">Ryan McGeary</a>&#8216;s WordPress plugin <a href="http://wordpress.org/extend/plugins/wp-syntax/">WP-Syntax</a> which uses <a href="http://qbnz.com/highlighter/">GeSHi</a> (Generic Syntax Highlighter), a simple highlighting class that supports multiple coding languages. It&#8217;s great but I&#8217;m not a fan of the horizontal scrollbar that appears if code extends past your site&#8217;s width. Instead, I decided to use <a href="http://jquery.com/">jQuery</a> to expand the box when you hover over it.<br />
<span id="more-1440"></span><br />
We need to make a few minor changes to the plugin code to get this to work. After you have downloaded, installed and activated the plugin, open up <code>wp-syntax.php</code> and go to line #113:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>113
114
115
116
117
118
119
120
121
122
123
124
125
126
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>line_numbers<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> wp_syntax_line_numbers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span><span style="color: #339933;">,</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</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: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$geshi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parse_code</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>We need to add a table to the second output.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">    if <span style="color: #00AA00;">&#40;</span>$line<span style="color: #00AA00;">&#41;</span>
    <span style="color: #00AA00;">&#123;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>line_numbers<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> wp_syntax_line_numbers<span style="color: #00AA00;">&#40;</span>$code<span style="color: #00AA00;">,</span> $line<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/td&gt;&lt;td class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> $geshi-<span style="color: #00AA00;">&gt;</span>parse_code<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
    else
    <span style="color: #00AA00;">&#123;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;div class=<span style="color: #000099; font-weight: bold;">\&quot;</span>code<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> $geshi-<span style="color: #00AA00;">&gt;</span>parse_code<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #00AA00;">;</span>
        $output .<span style="color: #00AA00;">=</span> <span style="color: #ff0000;">&quot;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Next we need to open up <code>wp-syntax.css</code> to change a few of the styles. Change this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_syntax</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#100</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;">#f9f9f9</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: #993333;">silver</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: #cc66cc;">0</span> <span style="color: #933;">1.5em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>to:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_syntax</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#100</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;">#f9f9f9</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: #993333;">silver</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: #cc66cc;">0</span> <span style="color: #933;">1.5em</span> <span style="color: #cc66cc;">0</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">590px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>I put a fixed width of 590px because I have set that as the maximum width of my single posts.</p>
<p>Now comes the <a href="http://jquery.com">jQuery</a>. Open up your theme&#8217;s <code>header.php</code> file and add the following between  your &lt;head&gt; tags.:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;?php wp_enqueue_script(&quot;jquery&quot;); ?&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>
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>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.wp_syntax&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> width <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;table&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> pad <span style="color: #339933;">=</span> width <span style="color: #339933;">+</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>width <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">590</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		jQuery<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: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</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>
				zIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100&quot;</span><span style="color: #339933;">,</span>
				position<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;relative&quot;</span>
			<span style="color: #009900;">&#125;</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> pad <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</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;">&#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>
			jQuery<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: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</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: #CC0000;">590</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>
<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></div></td></tr></table></div>

<p>What we are doing above is creating an effect that will only occur when you hover over the code box. It finds the width of the table and animates the expansion to the full width. When you hover out, the box returns to the fixed width of your post. Be sure that you set the two references to <em>590</em> to whatever you set your width to in the CSS.</p>
<p>Done and done!</p>
<p>To see this in action check out <a href="http://bavotasan.com/tutorials/how-to-create-a-twitter-feed-on-your-web-site/">How to Create a Twitter Feed on Your Web Site</a>.</p>
<p><strong>Resource</strong>: <a href="http://digwp.com/2009/07/making-an-expanding-code-box/">Making an Expanding Code Box by Chris Coyier</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/using-jquery-to-make-an-expandable-code-box-for-wp-syntax/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

