<?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>Codrops &#187; slide out</title>
	<atom:link href="http://tympanus.net/codrops/tag/slide-out/feed/" rel="self" type="application/rss+xml" />
	<link>http://tympanus.net/codrops</link>
	<description>Useful resources and inspiration for creative minds</description>
	<lastBuildDate>Wed, 23 May 2012 09:46:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to spice up your menu with CSS3</title>
		<link>http://tympanus.net/codrops/2012/01/22/how-to-spice-up-your-menu-with-css3/</link>
		<comments>http://tympanus.net/codrops/2012/01/22/how-to-spice-up-your-menu-with-css3/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 12:51:40 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=7369</guid>
		<description><![CDATA[Quick tip on how to spice up your menu with CSS3: add an image to every menu item and slide it out on hover.]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/"><img src="http://tympanus.net/codrops/wp-content/uploads/2012/01/CSS3MenuHoverEffect.jpg" alt="CSS3MenuHoverEffect" title="" width="580" height="315" class="alignnone size-full wp-image-7370" /></a></p>
<p><a class="demo" href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/" >View demo</a> <a class="download" href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/CSS3MenuHoverEffect.zip">Download source</a></p>
<p>In this new category called &#8220;Tips and Tricks&#8221; we will introduce some quick and interesting methods around web development and web design. In today&#8217;s tip we&#8217;ll show you how to spice up your menu by adding a neat hover effect to it. The idea is to slide an image out to the right when hovering over a menu item.</p>
<p>Each menu item (which is a unordered list item in this case) will have an anchor containing two spans and an image:</p>
<pre class="brush:xml">
&lt;ul class="mh-menu"&gt;
	&lt;li&gt;
		&lt;a href="#"&gt;
			&lt;span&gt;Art Director&lt;/span&gt;
			&lt;span&gt;Henry James&lt;/span&gt;
		&lt;/a&gt;
		&lt;img src="images/1.jpg" alt="image01"/&gt;
	&lt;/li&gt;
	&lt;!-- ... --&gt;
&lt;/ul&gt;
</pre>
<p>We&#8217;ll give <strong>.mh-menu li a</strong> display block and <strong>rgba(255,255,255, 0.8)</strong> as background color. When we hover over a list item, we&#8217;ll color the background into rgba(225,239,240, 0.4) which is a light blue:</p>
<pre class="brush:css">
.mh-menu li:hover a{
	background: rgba(225,239,240, 0.4);
}
</pre>
<p>The second span will also change its color on hover, but we want to change each item into a different color. So, we&#8217;ll add a color transition and get each different element with the nth-child selector:</p>
<pre class="brush:css">
.mh-menu li a span:nth-child(2){
	/*...*/
	transition: color 0.2s linear;
}
.mh-menu li:nth-child(1):hover span:nth-child(2){
	color: #ae3637;
}
.mh-menu li:nth-child(2):hover span:nth-child(2){
	color: #c3d243;
}
.mh-menu li:nth-child(3):hover span:nth-child(2){
	color: #d38439;
}
.mh-menu li:nth-child(4):hover span:nth-child(2){
	color: #8e7463;
}
</pre>
<p>The image will slide to the right side, so initially, it will have a left of 0px. We&#8217;ll also add a transition for its opacity; it will animate from 0 (initial value) to 1:</p>
<pre class="brush:css">
.mh-menu li img{
	position: absolute;
	z-index: 1;
	left: 0px;
	top: 0px;
	opacity: 0;
	transition: left 0.4s ease-in-out, opacity 0.6s ease-in-out;
}
.mh-menu li:hover img{
	left: 300px;
	opacity: 1;
}
</pre>
<p>And voilà, there we have our nice slide out effect!<br />
Make sure, that the z-index of the anchor is set to something higher than the image so that it slides under the anchor and not on top of it.</p>
<p>Alternatively, we can make the background color of the anchor become opaque on hover, i.e. completely white (<a href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/index2.html">demo 2</a>), or color each child differently (<a href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/index3.html">demo 3</a>).</p>
<p>The illustrations in the demo are by <a href="http://www.bartoszkosowski.com/">Bartosz Kosowski</a> (<a href="http://creativecommons.org/licenses/by-nc/3.0/">CC BY-NC 3.0</a>).</p>
<p><a class="demo" href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/" >View demo</a> <a class="download" href="http://tympanus.net/TipsTricks/CSS3MenuHoverEffect/CSS3MenuHoverEffect.zip">Download source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2012/01/22/how-to-spice-up-your-menu-with-css3/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Expanding Image Menu with jQuery</title>
		<link>http://tympanus.net/codrops/2011/03/16/expanding-image-menu/</link>
		<comments>http://tympanus.net/codrops/2011/03/16/expanding-image-menu/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 12:00:13 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[slide out]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=4469</guid>
		<description><![CDATA[View demoDownload source In today&#8217;s tutorial we will create an expanding image menu with jQuery. The idea is to have some columns with black and white image slices that will make a content area slide out when we click on them. We will also slide in the colored version of the image, creating a neat [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/03/expandingimagemenu.jpg" alt="" title="expandingimagemenu" width="580" height="315" class="aligncenter size-full wp-image-4481" /></a><br />
<a class="demo" href="http://tympanus.net/Tutorials/ExpandingImageMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ExpandingImageMenu/ExpandingImageMenu.zip">Download source</a></p>
<p>In today&#8217;s tutorial we will create an expanding image menu with jQuery. The idea is to have some columns with black and white image slices that will make a content area slide out when we click on them. We will also slide in the colored version of the image, creating a neat effect.</p>
<p>The photography is by talented <a href="http://www.flickr.com/people/robnas/" target="_blank">Robert Bejil</a>, check out his awesome photos on his <a target="_blank" href="http://www.flickr.com/photos/robnas/">Flickr photostream</a>.</p>
<p>So, let&#8217;s get started!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure consists of a main container and an unordered list where each item is one of the columns. We will give the main container the class &#8220;ei_menu&#8221; and also the id &#8220;ei_menu&#8221;. The list items are going to contain a link element with two spans inside and a div element with the content. The two spans are for the background image shown at the beginning and the colored version of the image for when we click on the item. Since we are using just one image for each we will have to define the background position. We will take care of that with the classes &#8220;pos1&#8243; to &#8220;pos5&#8243; that we will give to the parent link element.</p>
<pre class="brush:xml">
&lt;div id="ei_menu" class="ei_menu"&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;a href="#" class="pos1"&gt;
				&lt;span class="ei_preview"&gt;&lt;/span&gt;
				&lt;span class="ei_image"&gt;&lt;/span&gt;
			&lt;/a&gt;
			&lt;div class="ei_descr"&gt;
				&lt;h2&gt;Gary&lt;/h2&gt;
				&lt;h3&gt;Vocals&lt;/h3&gt;
				&lt;p&gt;Some text here...&lt;/p&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt; ... &lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>Let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>We are going to stretch the container for the list over the page and hide the overflow. Since we will adjust the size of the ul, we don&#8217;t want anything sticking out because of the slide out effect, to affect our container:</p>
<pre class="brush:css">
.ei_menu{
	background:#111;
	width:100%;
	overflow:hidden;
}
</pre>
<p>We will give enough width to the ul so that the li elements which will be floating, don&#8217;t wrap to the next &#8220;line&#8221; when they expand:</p>
<pre class="brush:css">
.ei_menu ul{
	height:350px;
	margin-left:50px;
	position:relative;
	display:block;
	width:1300px;
}
</pre>
<p>The overflow of the li elements is going to be hidden as well because our content inside is actually much bigger. And we only want to show that content, once we expand the while thing by increasing the width of the li:</p>
<pre class="brush:css">
.ei_menu ul li{
	float:left;
	width:75px;
	height:350px;
	position:relative;
	overflow:hidden;
	border-right:2px solid #111;
}
</pre>
<p>The &#8220;ei_preview&#8221; span will contain the black and white background image and will be of absolute positioning:</p>
<pre class="brush:css">
.ei_preview{
	width:75px;
	height:350px;
	cursor:pointer;
	position:absolute;
	top:0px;
	left:0px;
	background:transparent url(../images/bw.jpg) no-repeat top left;
}
</pre>
<p>The &#8220;ei_image&#8221; span will have the colored background image and be almost transparent. We will animate its position and also its opacity to create a cool effect:</p>
<pre class="brush:css">
.ei_image{
	position:absolute;
	left:75px;
	top:0px;
	width:75px;
	height:350px;
	opacity:0.2;
	background:transparent url(../images/color.jpg) no-repeat top left;
}
</pre>
<p>To define the positioning of the background for both spans, we will use the following classes, that we give to the parent link element:</p>
<pre class="brush:css">
.pos1 span{
	background-position:0px 0px;
}
.pos2 span{
	background-position:-75px 0px;
}
.pos3 span{
	background-position:-152px 0px;
}
.pos4 span{
	background-position:-227px 0px;
}
.pos5 span{
	background-position:-302px 0px;
}
.pos6 span{
	background-position:-377px 0px;
}
</pre>
<p>The content div will also have an absolute position and the left value is going to be the width of the spans:</p>
<pre class="brush:css">
.ei_descr{
	position:absolute;
	width:278px;
	height:310px;
	border-right:7px solid #f0f0f0;
	padding:20px;
	left:75px;
	top:0px;
	background:#fff;
}
</pre>
<p>We&#8217;ll spice up the heading of the content area with a nice grungy font that we&#8217;ll get from the Google fonts. We&#8217;ll also add some neat background stripes:</p>
<pre class="brush:css">
.ei_descr h2{
	font-family: 'Rock Salt', arial, serif;
	font-size:26px;
	color:#333;
	padding:10px;
	text-shadow:0px 0px 1px #fff;
	background:#fff url(../images/stripe_light.gif) repeat top left;
}
</pre>
<p>The sub heading will also have a font from the collection of Google fonts:</p>
<pre class="brush:css">
.ei_descr h3{
	font-family: 'Raleway', arial, serif;
	color:#fff;
	text-shadow:0px 0px 1px #000;
	font-style:normal;
	padding:10px;
	background:#333;
}
</pre>
<p>And finally, we style the paragraphs:</p>
<pre class="brush:css">
.ei_descr p{
	color:#000;
	padding:10px 5px 0px 5px;
	line-height:18px;
	font-size:11px;
	font-family: Arial, sans-serif;
	text-transform:uppercase;
}
</pre>
<p>And that&#8217;s all the style!<br />
Don&#8217;t forget to include the fonts that you are using from Google:</p>
<pre class="brush:xml">
&lt;link href='http://fonts.googleapis.com/css?family=Rock+Salt' rel='stylesheet' type='text/css' /&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Raleway:100' rel='stylesheet' type='text/css' /&gt;
</pre>
<p>This is added to the head of your HTML file.<br />
And now, let&#8217;s spice it up and add the magic!</p>
<h3>The JavaScript</h3>
<p>The main idea is to expand a menu item when clicking on it. This means that we want to animate the width of the li to 400 pixel (which is its initial width and the width of the spans, 75 pixel, plus the width of the content area which is 325 pixel counting with the padding and the border). While we do that, we also want to slide in the second span which has the colored background image and animate its opacity. We also want to decrease the opacity of the other items in order to enhance the current one. This will look as if they get darkened because we have a dark background.</p>
<p>Let&#8217;s begin by caching some elements:</p>
<pre class="brush:js">
var $menu				= $('#ei_menu > ul'),
	$menuItems			= $menu.children('li'),
	$menuItemsImgWrapper= $menuItems.children('a'),
	$menuItemsPreview	= $menuItemsImgWrapper.children('.ei_preview'),
	totalMenuItems		= $menuItems.length,
</pre>
<p>And let&#8217;s define the functionality:</p>
<pre class="brush:js">
ExpandingMenu 	= (function(){
	/*
		@current
		set it to the index of the element you want to be opened by default,
		or -1 if you want the menu to be closed initially
	 */
	var current				= -1,
	/*
		@anim
		if you want the default opened item to animate initially, set this to true
	 */
	anim				= true,
	/*
		checks if the current value is valid -
		between 0 and the number of items
	 */
	validCurrent		= function() {
		return (current &gt;= 0 &#038;&#038; current &lt; totalMenuItems);
	},
	init				= function() {
			/* show default item if current is set to a valid index */
		if(validCurrent())
			configureMenu();

		initEventsHandler();
	},
	configureMenu		= function() {
			/* get the item for the current */
		var $item	= $menuItems.eq(current);
			/* if anim is true, slide out the item */
		if(anim)
			slideOutItem($item, true, 900, 'easeInQuint');
		else{
				/* if not, just show it */
			$item.css({width : '400px'})
			.find('.ei_image')
			.css({left:'0px', opacity:1});

				/* decrease the opacity of the others */
				$menuItems.not($item)
						  .children('.ei_preview')
						  .css({opacity:0.2});
		}
	},
	initEventsHandler	= function() {
			/*
			when we click an item the following can happen:
			1) The item is already opened - close it!
			2) The item is closed - open it! (if another one is opened, close that one!)
			*/
		$menuItemsImgWrapper.bind('click.ExpandingMenu', function(e) {
			var $this 	= $(this).parent(),
			idx		= $this.index();

			if(current === idx) {
				slideOutItem($menuItems.eq(current), false, 1500, 'easeOutQuint', true);
				current = -1;
			}
			else{
				if(validCurrent() &#038;&#038; current !== idx)
						slideOutItem($menuItems.eq(current), false, 250, 'jswing');

				current	= idx;
					slideOutItem($this, true, 250, 'jswing');
			}
			return false;
		});
	},
		/* if you want to trigger the action to open a specific item */
		openItem			= function(idx) {
			$menuItemsImgWrapper.eq(idx).click();
		},
		/*
		opens or closes an item
		note that "mLeave" is just true when all the items close,
		in which case we want that all of them get opacity 1 again.
		"dir" tells us if we are opening or closing an item (true | false)
		*/
	slideOutItem		= function($item, dir, speed, easing, mLeave) {
		var $ei_image	= $item.find('.ei_image'),

		itemParam	= (dir) ? {width : '400px'} : {width : '75px'},
		imageParam	= (dir) ? {left : '0px'} : {left : '75px'};

			/*
			if opening, we animate the opacity of all the elements to 0.1.
			we do this in order to enhance the opened item more:
			*/
		if(dir)
		/*
				alternative:
				$menuItemsPreview.not($menuItemsPreview.eq(current))
								 .stop()
								 .animate({opacity:0.1}, 500);
		 */
			$menuItemsPreview.stop()
		.animate({opacity:0.1}, 1000);
		else if(mLeave)
			$menuItemsPreview.stop()
		.animate({opacity:1}, 1500);

			/* the &lt;li&gt; expands or collapses */
		$item.stop().animate(itemParam, speed, easing);
			/* the image span (color) slides in or out */
		$ei_image.stop().animate(imageParam, speed, easing, function() {
				/*
				if opening, we animate the opacity to 1,
				otherwise we reset it.
				*/
			if(dir)
				$ei_image.animate({opacity:1}, 2000);
			else
				$ei_image.css('opacity', 0.2);
		});
	};

	return {
		init 		: init,
		openItem	: openItem
	};
})();

/*
call the init method of ExpandingMenu
 */
ExpandingMenu.init();

/*
if you want to open / close a specific item you could do it like this:
ExpandingMenu.openItem(3); // toggles item 3 (zero-based indexing)
*/
</pre>
<p>And that&#8217;s all!</p>
<h3>Alternative Demos</h3>
<p>You can check out the following other demos which all make use of the different options in our script:</p>
<ul>
<li><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/index_1.html">One item opened already</a></li>
<li><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/index_2.html">One item will open (animate) on page load</a></li>
<li><a target="_blank" href="http://tympanus.net/Tutorials/ExpandingImageMenu/index_3.html">Example of how to trigger the opening/closing the menu items</a></li>
</ul>
<p>All of these versions will be included in the ZIP file.<br />
We hope you enjoyed the tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/ExpandingImageMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ExpandingImageMenu/ExpandingImageMenu.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/03/16/expanding-image-menu/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Overlay Effect Menu with jQuery</title>
		<link>http://tympanus.net/codrops/2010/11/25/overlay-effect-menu/</link>
		<comments>http://tympanus.net/codrops/2010/11/25/overlay-effect-menu/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 21:11:45 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[overlay]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=3119</guid>
		<description><![CDATA[View demoDownload source In this tutorial we are going to create a simple menu that will stand out once we hover over it by covering everything except the menu with a dark overlay. The menu will stay white and a submenu area will expand. We will create this effect using jQuery. So, let&#8217;s start! The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/OverlayEffectMenu/" target="_blank"><img class="aligncenter size-full wp-image-3124" title="overlayEffectMenu" src="http://tympanus.net/codrops/wp-content/uploads/2010/11/overlayEffectMenu.jpg" alt="" width="580" height="315" /></a><br />
<a class="demo" href="http://tympanus.net/Tutorials/OverlayEffectMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/OverlayEffectMenu/OverlayEffectMenu.zip">Download source</a><br />
In this tutorial we are going to create a simple menu that will stand out once we hover over it by covering everything except the menu with a dark overlay. The menu will stay white and a submenu area will expand. We will create this effect using jQuery.</p>
<p>So, let&#8217;s start!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure will consist of a main wrapper div for the menu which will contain the overlay and the unordered list for the menu. The menu itself will have a link and a div element as submenu in its list elements. Each of the submenu elements will contain lists for the columns of the submenu where each one will have a heading list element:</p>
<pre class="brush:xml">&lt;div class="oe_wrapper"&gt;
	&lt;div id="oe_overlay" class="oe_overlay"&gt;&lt;/div&gt;
	&lt;ul id="oe_menu" class="oe_menu"&gt;
		&lt;li&gt;
			&lt;a href=""&gt;Collections&lt;/a&gt;
			&lt;div&gt;
				&lt;ul&gt;
					&lt;li class="oe_heading"&gt;
						Summer 2011
					&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Milano&lt;/a&gt;&lt;/li&gt;
					...
				&lt;/ul&gt;
				&lt;ul&gt;
					...
				&lt;/ul&gt;
				&lt;ul&gt;
					...
				&lt;/ul&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=""&gt;Projects&lt;/a&gt;
			&lt;div style="left:-111px;"&gt;
				...
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=""&gt;Fragrances&lt;/a&gt;
			&lt;div style="left:-223px;"&gt;
				&lt;ul class="oe_full"&gt;
					&lt;li class="oe_heading"&gt;
						Fashion Fragrances
					&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Deálure&lt;/a&gt;&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Violet Woman&lt;/a&gt;&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Deep Blue for Men&lt;/a&gt;&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;New York, New York&lt;/a&gt;&lt;/li&gt;
					&lt;li&gt;&lt;a href="#"&gt;Illusion&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=""&gt;Events&lt;/a&gt;
			&lt;div style="left:-335px;"&gt;
				...
			&lt;/div&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=""&gt;Stores&lt;/a&gt;
			&lt;div style="left:-447px;"&gt;
				...
			&lt;/div&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>The submenu divs will each have an inline style for the left position. As we will see, when we look at the style, we need to set this value since we want the submenu to be of absolute position, but within a relatively positioned container. So, in order to position all of the submenu divs at the beginning of the whole menu, we need to &#8220;pull&#8221; each div more to the left, hence we will have a negative left value for each div (decrementing 112px).</p>
<p>Let&#8217;s look at the style.</p>
<h3>The CSS</h3>
<p>Make sure, that you reset the styles first (we don&#8217;t want any browser-defined padding or margin for the list). We will start by the overlay for the body, which is a simple div with an initial opacity of 0:</p>
<pre class="brush:css">.oe_overlay{
	background:#000;
	opacity:0;
	position:fixed;
	top:0px;
	left:0px;
	width:100%;
	height:100%;
}
</pre>
<p>The position will be set to fixed, since we want it to always stay on the top left corner filling the whole screen.<br />
The main menu list will have the following style:</p>
<pre class="brush:css">ul.oe_menu{
	list-style:none;
	position:relative;
	margin:30px 0px 0px 40px;
	width:560px;
	float:left;
	clear:both;
}
</pre>
<p>You might want to adapt its floatiness once you are planning to integrate this somewhere on your site. What is important, is the positioning of the list items:</p>
<pre class="brush:css">ul.oe_menu &gt; li{
	width:112px;
	height:101px;
	padding-bottom:2px;
	float:left;
	position:relative;
}
</pre>
<p>They will be positioned relatively so that we can have the absolutely positioned submenu elements.<br />
The anchor of the top layer menu will have the following style, forming the box:</p>
<pre class="brush:css">ul.oe_menu &gt; li &gt; a{
	display:block;
	background-color:#101010;
	color:#aaa;
	text-decoration:none;
	font-weight:bold;
	font-size:12px;
	width:90px;
	height:80px;
	padding:10px;
	margin:1px;
	text-shadow:0px 0px 1px #000;
	opacity:0.8;
}
ul.oe_menu &gt; li &gt; a:hover,
ul.oe_menu &gt; li.selected &gt; a{
	background:#fff;
	color:#101010;
	opacity:1.0;
}
</pre>
<p>In our JavaScript we will add the class &#8220;hovered&#8221; to the main ul, once we move with the mouse over the menu, so that we can change all the anchors to white:</p>
<pre class="brush:css">.oe_wrapper ul.hovered &gt; li &gt; a{
	background:#fff;
	text-shadow:0px 0px 1px #FFF;
}
</pre>
<p>The submenu element will not be visible at the beginning, but only slide in when we hover over a top layer list element:</p>
<pre class="brush:css">ul.oe_menu div{
	position:absolute;
	top:103px;
	left:1px;
	background:#fff;
	width:498px;
	height:180px;
	padding:30px;
	display:none;
}
</pre>
<p>The style for the links inside of the submenu lists:</p>
<pre class="brush:css">ul.oe_menu div ul li a{
	text-decoration:none;
	color:#222;
	padding:2px 2px 2px 4px;
	margin:2px;
	display:block;
	font-size:12px;
}
ul.oe_menu div ul li a:hover{
	background:#000;
	color:#fff;
}
</pre>
<p>One of our submenu lists will be alone, so we want it to take all the space:</p>
<pre class="brush:css">ul.oe_menu div ul.oe_full{
	width:100%;
}
</pre>
<p>And if it&#8217;s not alone, we want it to have a width of 150px, so that we can have 3 floating next to each other:</p>
<pre class="brush:css">ul.oe_menu li ul{
	list-style:none;
	float:left;
	width: 150px;
	margin-right:10px;
}
</pre>
<p>And finally, we want the heading of the submenu list to stand out:</p>
<pre class="brush:css">li.oe_heading{
	color:#aaa;
	font-size:16px;
	margin-bottom:10px;
	padding-bottom:6px;
	border-bottom:1px solid #ddd;
}
</pre>
<p>And that&#8217;s all the style! Let&#8217;s continue with the effects using jQuery.</p>
<h3>The JavaScript</h3>
<p>The main idea is to make an overlay appear that darkens everything on the page except the menu. We guarantee that the overlay stays under the menu because we placed it before the menu in the HTML structure. And the overlay stays on top of everything else because it all comes before in the HTML stucture. So, the z-indexes are in the wanted order. Consider that if you integrate this menu somewhere.</p>
<p>Let&#8217;s first cache some elements:</p>
<pre class="brush:js">var $oe_menu		= $('#oe_menu');
var $oe_menu_items	= $oe_menu.children('li');
var $oe_overlay		= $('#oe_overlay');
</pre>
<p>When we hover any of the menu items, we will add the classes &#8220;slided&#8221; and &#8220;selected&#8221; to the item. The corresponding submenu div will get slided out and all the other ones will get hidden. We also give a very high z-index to the current submenu. When we move the mouse out, we will remove the class &#8220;selected&#8221;:</p>
<pre class="brush:js">$oe_menu_items.bind('mouseenter',function(){
	var $this = $(this);
	$this.addClass('slided selected');
	$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
		$oe_menu_items.not('.slided').children('div').hide();
		$this.removeClass('slided');
	});
}).bind('mouseleave',function(){
	var $this = $(this);
	$this.removeClass('selected').children('div').css('z-index','1');
});
</pre>
<p>The class &#8220;selected&#8221; is needed for the style, while the class &#8220;slided&#8221; is a helper class that let&#8217;s us identify which item is currently &#8220;in use&#8221;.</p>
<p>Now, we will take care of the overlay by defining what happens when we enter the whole menu wrapper. We will fade the overlay to an opacity of 0.6 and add the class &#8220;hovered&#8221; to the wrapper, so that the anchors stay white:</p>
<pre class="brush:js">$oe_menu.bind('mouseenter',function(){
	var $this = $(this);
	$oe_overlay.stop(true,true).fadeTo(200, 0.6);
	$this.addClass('hovered');
}).bind('mouseleave',function(){
	var $this = $(this);
	$this.removeClass('hovered');
	$oe_overlay.stop(true,true).fadeTo(200, 0);
	$oe_menu_items.children('div').hide();
})
</pre>
<p>And that&#8217;s it! We hope you had fun with this tutorial and found it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/OverlayEffectMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/OverlayEffectMenu/OverlayEffectMenu.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/11/25/overlay-effect-menu/feed/</wfw:commentRss>
		<slash:comments>83</slash:comments>
		</item>
		<item>
		<title>Related Posts Slide Out Boxes with jQuery and CSS3</title>
		<link>http://tympanus.net/codrops/2010/07/21/related-posts-slide-out-boxes/</link>
		<comments>http://tympanus.net/codrops/2010/07/21/related-posts-slide-out-boxes/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 10:37:16 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2647</guid>
		<description><![CDATA[View demoDownload source The other day we were wondering how we could show our visitors more of our works. It&#8217;s normal that in a blog older posts get forgotten and even if something might still be very interesting and relevant, it get&#8217;s lost under the pile of new stuff. So we decided to create something [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/RelatedPostsSlideOuts/" target="_blank"><img class="aligncenter size-full wp-image-2653" title="relatedpostsslideouts" src="http://tympanus.net/codrops/wp-content/uploads/2010/07/relatedpostsslideouts.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/RelatedPostsSlideOuts/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/RelatedPostsSlideOuts/RelatedPostsSlideOuts.zip">Download source</a></p>
<p>The other day we were wondering how we could show our visitors more of our works. It&#8217;s normal that in a blog older posts get forgotten and even if something might still be very interesting and relevant, it get&#8217;s lost under the pile of new stuff. So we decided to create something like a little widget that can be used to show related posts in any page. The main idea is to show a fixed list at the right side of the screen with some thumbnails sticking out. When the user hovers over the items, they slide out, revealing the title and two links, one for the related article itself and one for the demo. Additionally, we will have a shuffle button under the list. When pressed, the list gets randomly refreshed with related posts.</p>
<p>Before we use this, we of course, want to share it with you :)</p>
<p>So, let&#8217;s get started!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure is going to be a list with some nested elements inside: the main div with the thumbnail, the span for the title and the span with the two links:</p>
<pre class="brush:xml">&lt;div id="rp_list" class="rp_list"&gt;
	&lt;ul&gt;
		&lt;li&gt;
			&lt;div&gt;
				&lt;img src="images/1.jpg" alt=""/&gt;
				&lt;span class="rp_title"&gt;Post Title&lt;/span&gt;
				&lt;span class="rp_links"&gt;
					&lt;a target="_blank" href="#"&gt;Article&lt;/a&gt;
					&lt;a target="_blank" href="#"&gt;Demo&lt;/a&gt;
				&lt;/span&gt;
			&lt;/div&gt;
		&lt;/li&gt;
		...
	&lt;/ul&gt;
	&lt;span id="rp_shuffle" class="rp_shuffle"&gt;&lt;/span&gt;
&lt;/div&gt;
</pre>
<p>All related posts are going to be listed in our structure. In the JavaScript we will define that we only show 5 posts at a time. Of course, you need to replace the # with your links.<br />
The shuffle span will be positioned after the list.</p>
<p>Let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>We will start by the general style attributes:</p>
<pre class="brush:css">.rp_list {
	font-family:Verdana, Helvetica, sans-serif;
	position:fixed;
	right:-220px;
	top:40px;
	margin:0;
	padding:0;
}
</pre>
<p>As you can see, the list will have a fixed position, always staying in the same place when the user scrolls the page. We are going to set the right to a negative value, hiding the whole list.</p>
<p>Next, let&#8217;s define the shuffle span style:</p>
<pre class="brush:css">span.rp_shuffle{
	background:#222 url(../images/shuffle.png) no-repeat 10px 50%;
	width:28px;
	height:14px;
	display:block;
	margin:10px 0px 0px 20px;
	cursor:pointer;
	padding:4px;
	border:1px solid #000;
	-moz-border-radius:5px 0px 0px 5px;
	-webkit-border-bottom-left-radius: 5px;
	-webkit-border-top-left-radius: 5px;
	border-bottom-left-radius: 5px;
	border-top-left-radius: 5px;
}
</pre>
<p>The list is going to have the following style:</p>
<pre class="brush:css">.rp_list ul{
	margin:0;
	padding:0;
	list-style:none;
}
</pre>
<p>The list items will not be shown initially:</p>
<pre class="brush:css">.rp_list ul li{
	width: 240px;
	margin-bottom:5px;
	display:none;
}
</pre>
<p>Our main elements will have the following style:</p>
<pre class="brush:css">.rp_list ul li div{
	display: block;
	line-height:15px;
	width: 240px;
	height: 80px;
	background:#333;
	border:1px solid #000;
	-moz-border-radius:5px 0px 0px 5px;
	-webkit-border-bottom-left-radius: 5px;
	-webkit-border-top-left-radius: 5px;
	border-bottom-left-radius: 5px;
	border-top-left-radius: 5px;
}
</pre>
<p>The thumbnail will be of the size 70&#215;70 pixel and we will add a box shadow to it:</p>
<pre class="brush:css">.rp_list ul li div img{
	width:70px;
	border:none;
	float:left;
	margin:4px 10px 0px 4px;
	border:1px solid #111;
	-moz-box-shadow:1px 1px 3px #000;
	-webkit-box-shadow:1px 1px 3px #000;
	box-shadow:1px 1px 3px #000;
}
</pre>
<p>The title span is going to have a inset shadow:</p>
<pre class="brush:css">span.rp_title{
	font-size:11px;
	color:#ddd;
	height:46px;
	margin:4px 0px 0px 20px;
	display:block;
	text-shadow:1px 1px 1px #000;
	padding-top:3px;
	background:#222;
	-moz-box-shadow:0px 0px 5px #000 inset;
	-webkit-box-shadow:0px 0px 5px #000 inset;
	box-shadow:0px 0px 5px #000 inset;
}
</pre>
<p>The span for the links and the buttons will have the following style:</p>
<pre class="brush:css">span.rp_links{
	width:195px;
	height:8px;
	padding-top:2px;
	display:block;
	margin-left:42px;
}
span.rp_links a{
	background: #222 url(../images/bgbutton.png) repeat-x;
	padding: 2px 18px;
	font-size:10px;
	color: #fff;
	text-decoration: none;
	line-height: 1;
	-moz-box-shadow: 0 1px 3px #000;
	-webkit-box-shadow: 0 1px 3px #000;
	box-shadow:0 1px 3px #000;
	text-shadow: 0 -1px 1px #222;
	cursor: pointer;
	outline:none;
}
span.rp_links a:hover{
	background-color:#000;
	color:#fff;
}
</pre>
<p>And that&#8217;s all the style. Let&#8217;s add some magic!</p>
<h3>The JavaScript</h3>
<p>The main idea is to first show 5 items with their whole width and to quickly slide them in until one can only see the thumbnail. That should happen when we load the page. It is a neat effect to show the user that there is something going on and that he can interact with this element.</p>
<p>When we hover over an item, we will make it slide out until its full width, revealing the title and the links.</p>
<p>The shuffle function will make 5 posts appear randomly. As you noticed, we added all our related posts to the HTML structure and from those items, we will randomly choose 5. This method does not guarantee us that the next set of items shown are not repeated, but it&#8217;s a simple solution.</p>
<p>We will add the following jQuery function:</p>
<pre class="brush:js">$(function() {
	/**
	* the list of posts
	*/
	var $list 		= $('#rp_list ul');
	/**
	* number of related posts
	*/
	var elems_cnt 		= $list.children().length;

	/**
	* show the first set of posts.
	* 200 is the initial left margin for the list elements
	*/
	load(200);

	function load(initial){
		$list.find('li').hide().andSelf().find('div').css('margin-left',-initial+'px');
		var loaded	= 0;
		//show 5 random posts from all the ones in the list.
		//Make sure not to repeat
		while(loaded &lt; 5){
			var r 		= Math.floor(Math.random()*elems_cnt);
			var $elem	= $list.find('li:nth-child('+ (r+1) +')');
			if($elem.is(':visible'))
				continue;
			else
				$elem.show();
			++loaded;
		}
		//animate them
		var d = 200;
		$list.find('li:visible div').each(function(){
			$(this).stop().animate({
				'marginLeft':'-50px'
			},d += 100);
		});
	}

	/**
	* hovering over the list elements makes them slide out
	*/
	$list.find('li:visible').live('mouseenter',function () {
		$(this).find('div').stop().animate({
			'marginLeft':'-220px'
		},200);
	}).live('mouseleave',function () {
		$(this).find('div').stop().animate({
			'marginLeft':'-50px'
		},200);
	});

	/**
	* when clicking the shuffle button,
	* show 5 random posts
	*/
	$('#rp_shuffle').unbind('click')
					.bind('click',shuffle)
					.stop()
					.animate({'margin-left':'-18px'},700);

	function shuffle(){
		$list.find('li:visible div').stop().animate({
			'marginLeft':'60px'
		},200,function(){
			load(-60);
		});
	}
});
</pre>
<p>And that&#8217;s all!</p>
<p>We hope you enjoyed this tutorial and found it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/RelatedPostsSlideOuts/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/RelatedPostsSlideOuts/RelatedPostsSlideOuts.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/07/21/related-posts-slide-out-boxes/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>Awesome Cufonized Fly-out Menu with jQuery and CSS3</title>
		<link>http://tympanus.net/codrops/2010/06/28/awesome-cufonized-fly-out-menu/</link>
		<comments>http://tympanus.net/codrops/2010/06/28/awesome-cufonized-fly-out-menu/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:34:14 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[cufon]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2472</guid>
		<description><![CDATA[View demoDownload source In today&#8217;s tutorial we will create a full page cufonized menu that has two nice features: when hovering over the menu items we will move a hover-state item that adapts to the width of the current item, and we will slide out a description bar from the left side of the page, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/CufonizedFlyOutMenu/" target="_blank"><img class="aligncenter size-full wp-image-2483" title="flyoutmenu" src="http://tympanus.net/codrops/wp-content/uploads/2010/06/flyoutmenu.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CufonizedFlyOutMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/CufonizedFlyOutMenu/CufonizedFlyOutMenu.zip">Download source</a></p>
<p>In today&#8217;s tutorial we will create a full page cufonized menu that has two nice features: when hovering over the menu items we will move a hover-state item that adapts to the width of the current item, and we will slide out a description bar from the left side of the page, reaching towards the current menu item.</p>
<p>We will use jQuery for the effect and some CSS3 properties for the style. We are not going to use any images.</p>
<p>So, let&#8217;s start!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure will consist of an unordered list that represents our menu and a div for the description elements:</p>
<pre class="brush:xml">&lt;div id="slidingMenuDesc" class="slidingMenuDesc"&gt;
	&lt;div&gt;&lt;span&gt;Description for "About"&lt;/span&gt;&lt;/div&gt;
	...
&lt;/div&gt;

&lt;ul id="slidingMenu" class="slidingMenu"&gt;
	&lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;Work&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;Contact&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;Get a quote&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>We leave out the description for &#8220;Home&#8221; since there is nothing to describe. The sliding divs should just appear when we hover over the other items.</p>
<h3>The CSS</h3>
<p>First, we will style the menu and its navigation items and then we will style the description elements.<br />
Let&#8217;s reset some styles:</p>
<pre class="brush:css">body, ul, li, h1, h2, span{
	margin:0;
	padding:0;
}
ul{
	list-style:none;
}
</pre>
<p>The background is going to be dark gray:</p>
<pre class="brush:css">body{
	background:#292929;
}
</pre>
<p>The list for the menu items is going to be positioned absolutely at the right side of the screen:</p>
<pre class="brush:css">.slidingMenu {
	position: absolute;
	height:410px;
	width: 410px;
	top:40px;
	overflow:hidden;
	right:1px;
	font-family: Arial, Helvetica, sans-serif;
}
</pre>
<p>The menu items are hoing to float right:</p>
<pre class="brush:css">.slidingMenu li {
	display:block;
	float:right;
	clear:both;
	position:relative;
	overflow:hidden;
}
</pre>
<p>The &#8220;mover&#8221; element will be positioned absolutely and we will give it a top and a width dynamically:</p>
<pre class="brush:css">.slidingMenu li.move {
	width: 9px;
	height: 68px;
	right:0px;
	padding-right:10px;
	margin-top:2px;
	z-index: 8;
	position: absolute;
	background: #2183c4;
	background:
		-webkit-gradient(
			linear,
			left top,
			left bottom,
			from(#0771b8),
			to(#2183c4)
		);
	background:
		-moz-linear-gradient(
			top,
			#0771b8,
			#2183c4
		);
	-moz-border-radius: 8px 0px 0px 8px;
	-webkit-border-top-left-radius: 8px;
	-webkit-border-bottom-left-radius: 8px;
	border-top-left-radius: 8px;
	border-bottom-left-radius: 8px;
	-moz-box-shadow:1px 1px 5px #000;
	-webkit-box-shadow:1px 1px 5px #000;
	box-shadow:1px 1px 5px #000;
	}
</pre>
<p>We will give this moving hover element a very subtle background gradient and some box shadow.<br />
The style for the link element will be as follows:</p>
<pre class="brush:css">.slidingMenu li a {
	font-size:66px;
	text-transform:uppercase;
	text-decoration: none;
	color: #ddd;
	outline: none;
	text-indent:5px;
	z-index: 10;
	display: block;
	float: right;
	height: 66px;
	line-height: 66px;
	position: relative;
	overflow: hidden;
	padding-right:10px;
}
</pre>
<p>The descriptions will be in a relatively positioned container. We set the margin-top to the same value like the top of the menu list:</p>
<pre class="brush:css">/* Descriptions */
.slidingMenuDesc{
	margin-top:40px;
	position:relative;
}
</pre>
<p>The div with the description span inside is going to have the same background-gradient like the mover and the same box shadow. The rounded borders are going to be on the opposite corners:</p>
<pre class="brush:css">.slidingMenuDesc div{
	background: #2183c4;
	background:
		-webkit-gradient(
			linear,
			left top,
			left bottom,
			from(#0771b8),
			to(#2183c4)
		);
	background:
		-moz-linear-gradient(
			top,
			#0771b8,
			#2183c4
		);
	height: 68px;
	padding-right:5px;
	left:-5px;
	width:0px;
	margin-top:2px;
	overflow:hidden;
	position:absolute;
	-moz-box-shadow:1px 1px 5px #000;
	-webkit-box-shadow:1px 1px 5px #000;
	box-shadow:1px 1px 5px #000;
	-moz-border-radius: 0px 8px 8px 0px;
	-webkit-border-top-right-radius: 8px;
	-webkit-border-bottom-right-radius: 8px;
	border-top-right-radius: 8px;
	border-bottom-right-radius: 8px;
}
</pre>
<p>We need to set these element absolute, since we will adjust the top to the according current list element that we are hovering.</p>
<p>The description span is going to be positioned absolutely as well. This is not required but it gives you more options if you would like to apply other animation effects:</p>
<pre class="brush:css">.slidingMenuDesc div span {
	font-size:36px;
	color: #f0f0f0;
	text-indent:5px;
	z-index: 10;
	display: block;
	height: 66px;
	line-height: 66px;
	position:absolute;
	right:10px;
	margin-left:5px;
	top:-3px;
}
</pre>
<p>And now, let&#8217;s take a look at the JavaScript!</p>
<h3>The JavaScript</h3>
<p>First, we will add the following scripts to our HTML head:</p>
<pre class="brush:xml">&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="cufon-yui.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="BabelSans_500.font.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="jquery.easing.1.3.js" type="text/javascript"&gt;&lt;/script&gt;
</pre>
<p>And we will add the following script:</p>
<pre class="brush:js">$(function() {
	Cufon.replace('a, span').CSS.ready(function() {
		var $menu 		= $("#slidingMenu");

		/**
		* the first item in the menu,
		* which is selected by default
		*/
		var $selected	= $menu.find('li:first');

		/**
		* this is the absolute element,
		* that is going to move across the menu items
		* It has the width of the selected item
		* and the top is the distance from the item to the top
		*/
		var $moving		= $('&lt;li /&gt;',{
			className	: 'move',
			top			: $selected[0].offsetTop + 'px',
			width		: $selected[0].offsetWidth + 'px'
		});

		/**
		* each sliding div (descriptions) will have the same top
		* as the corresponding item in the menu
		*/
		$('#slidingMenuDesc &gt; div').each(function(i){
			var $this = $(this);
			$this.css('top',$menu.find('li:nth-child('+parseInt(i+2)+')')[0].offsetTop + 'px');
		});

		/**
		* append the absolute div to the menu;
		* when we mouse out from the menu
		* the absolute div moves to the top (like initially);
		* when hovering the items of the menu, we move it to its position
		*/
		$menu.bind('mouseleave',function(){
				moveTo($selected,400);
			  })
			 .append($moving)
			 .find('li')
			 .not('.move')
			 .bind('mouseenter',function(){
				var $this = $(this);
				var offsetLeft = $this.offset().left - 20;
				//slide in the description
				$('#slidingMenuDesc &gt; div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':offsetLeft+'px'},400, 'easeOutExpo');
				//move the absolute div to this item
				moveTo($this,400);
			  })
			  .bind('mouseleave',function(){
				var $this = $(this);
				var offsetLeft = $this.offset().left - 20;
				//slide out the description
				$('#slidingMenuDesc &gt; div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':'0px'},400, 'easeOutExpo');
			  });;

		/**
		* moves the absolute div,
		* with a certain speed,
		* to the position of $elem
		*/
		function moveTo($elem,speed){
			$moving.stop(true).animate({
				top		: $elem[0].offsetTop + 'px',
				width	: $elem[0].offsetWidth + 'px'
			}, speed, 'easeOutExpo');
		}
	}) ;
});
</pre>
<p>After we cufonize the font (all &#8220;a&#8221; elements and all &#8220;span&#8221; elements), the main function gets executed. We select the first item by default which is our &#8220;Home&#8221;. When we hover over a menu item we will move the li.move to the right position and slide out the according description item.</p>
<p>And that&#8217;s it! We hope you enjoyed it and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CufonizedFlyOutMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/CufonizedFlyOutMenu/CufonizedFlyOutMenu.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/06/28/awesome-cufonized-fly-out-menu/feed/</wfw:commentRss>
		<slash:comments>115</slash:comments>
		</item>
		<item>
		<title>UI Elements: Combo Box, Pop Out and Horizontal Slide Out Menu</title>
		<link>http://tympanus.net/codrops/2010/06/21/ui-elements-combobox/</link>
		<comments>http://tympanus.net/codrops/2010/06/21/ui-elements-combobox/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 23:55:50 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[combo box]]></category>
		<category><![CDATA[horizontal]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[slide out]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2395</guid>
		<description><![CDATA[Today we will show you some useful and neat UI elements that are focused on selecting content. We will be using jQuery and some CSS3 properties for the style to give the elements some edge. The first element is going to be a select box plugin that let&#8217;s you create an auto scrolling combo box. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://tympanus.net/codrops/wp-content/uploads/2010/06/uielements.jpg" alt="" title="uielements" width="580" height="315" class="aligncenter size-full wp-image-2426" /></p>
<p>Today we will show you some useful and neat UI elements that are focused on selecting content. We will be using jQuery and some CSS3 properties for the style to give the elements some edge.</p>
<p>The first element is going to be a select box plugin that let&#8217;s you create an auto scrolling combo box. The second element will be a popout menu that reveals its items once it&#8217;s clicked, and the third one is going to be a vertical slide out menu.</p>
<h3>Auto Scrolling ComboBox</h3>
<p><img class="aligncenter size-full wp-image-2414 nofancy" title="Combo" src="http://tympanus.net/codrops/wp-content/uploads/2010/06/Combo.png" alt="" width="580" height="190" /><br />
This plugin will transform a select element into a nice looking combo box. You just need to give an ID to the select box and call the plugin like this:</p>
<pre class="brush:js">
$(function() {
    $('#ui_element').scrollablecombo();
});
</pre>
<p><a class="demo" href="http://tympanus.net/Tutorials/UIElements/ScrollableCombo/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/UIElements/ScrollableCombo/ScrollableCombo.zip">Download source</a></p>
<div class="clr"></div>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>Popout Menu</h3>
<p><img src="http://tympanus.net/codrops/wp-content/uploads/2010/06/popout.png" alt="" title="popout" width="580" height="190" class="aligncenter size-full wp-image-2420 nofancy" /><br />
The Popout Menu let&#8217;s you display menu options in a vertical manner. When clicked, the menu shows its items in a stack manner.<br />
<a class="demo" href="http://tympanus.net/Tutorials/UIElements/PopoutMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/UIElements/PopoutMenu/PopoutMenu.zip">Download source</a></p>
<div class="clr"></div>
<h3>Horizontal Slide Out Menu</h3>
<p><img src="http://tympanus.net/codrops/wp-content/uploads/2010/06/slideout.png" alt="" title="slideout" width="580" height="190" class="aligncenter size-full wp-image-2421 nofancy" /><br />
The horizontal slide out menu is positioned at the left hand side of the window and slides out its menu items once the arrow is clicked. The arrow bounces back once the mouse leaves and this creates a neat effect.<br />
<a class="demo" href="http://tympanus.net/Tutorials/UIElements/SlideOutMenu/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/UIElements/SlideOutMenu/SlideOutMenu.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/06/21/ui-elements-combobox/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Fresh Sliding Thumbnails Gallery with jQuery and PHP</title>
		<link>http://tympanus.net/codrops/2010/05/23/fresh-sliding-thumbnails-gallery-with-jquery-php/</link>
		<comments>http://tympanus.net/codrops/2010/05/23/fresh-sliding-thumbnails-gallery-with-jquery-php/#comments</comments>
		<pubDate>Sun, 23 May 2010 21:55:52 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[scrolling]]></category>
		<category><![CDATA[slide out]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2147</guid>
		<description><![CDATA[View demoDownload source In this tutorial we are going to create another full page image gallery with a nice thumbnail area that scrolls automatically when moving the mouse. The idea is to allow the user to slightly zoom into the picture by clicking on it. The thumbnails bar slides down and the image resizes according [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGallery/" target="_blank"><img class="aligncenter size-full wp-image-2254" title="freshslidingthumbnaislgallery" src="http://tympanus.net/codrops/wp-content/uploads/2010/05/freshslidingthumbnaislgallery1.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGallery/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGallery/FreshSlidingThumbnailsGallery.zip">Download source</a></p>
<p>In this tutorial we are going to create another full page image gallery with a nice thumbnail area that scrolls automatically when moving the mouse. The idea is to allow the user to slightly zoom into the picture by clicking on it. The thumbnails bar slides down and the image resizes according to the screen size.</p>
<p>The scrolling functionality of the thumbnails bar is based on the great tutorial by Andrew Valums: <a href="http://valums.com/scroll-menu-jquery/" target="_blank">Horizontal Scrolling Menu made with CSS and jQuery</a>.<br />
Additionally, we will be using PHP to get the images and thumbs automatically from the folder structure. The folders will contain album sub-folders and we will add a select option to the gallery which allows to choose an album.</p>
<p>Just like in the <a href="http://tympanus.net/codrops/2010/05/14/sliding-panel-photo-wall-gallery-with-jquery/" target="_blank">Sliding Panel Photo Wall Gallery with jQuery</a> we will be using a resize function for the image displayed.</p>
<p>We will also add an XML file that (optionally) contains the descriptions of the images.</p>
<p>Another neat functionality that we are going to add is the changing cursor: depending in which mode and in which position of the full image we are, the cursor will change to a left or right arrow (for browsing the pictures), or to a plus or minus sign (for zooming in or out).</p>
<p>The beautiful images in the demo are from the <a href="http://www.flickr.com/photos/2dogs_productions/sets/72157594522520053/">Models 1 &#8211; Photoshoots</a> album from Vincent Boiteau&#8217;s photostream on Flickr.</p>
<p><strong>We also have a static version of the image gallery without the album option. You can find the demo link and the ZIP file in the <a href="#theendofpost">end of this post</a></strong>.</p>
<p>And don&#8217;t forget to check out the tutorial of the  mobile version of this gallery: <a href="../2010/05/27/awesome-mobile-image-gallery-web-app/" target="_blank">Awesome Mobile Image Gallery Web App</a></p>
<p>So, let&#8217;s start!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Folder Structure</h3>
<p>Today we will start this tutorial by the folder structure since it is important for our PHP functionality.</p>
<p>The necessary folders for the PHP to work are the images folder and the thumbs folder. They both need to be located in the root folder (where you will have the index.php file).</p>
<p>Whatever album sub-folder will be in the thumbs folder, also needs to be in the images folder. So, if we have <strong>thumbs/album1/22.jpg</strong> we also need <strong>images/album1/22.jpg</strong> which will be the full-size image.</p>
<p style="text-align: center;"><img class="nofancy size-full wp-image-2155  aligncenter" title="folderstructure" src="http://tympanus.net/codrops/wp-content/uploads/2010/05/folderstructure.jpg" alt="" width="489" height="257" /></p>
<p>With that organization we will be able to automatically display the album thumbnails and create a select box for all albums.</p>
<p>In each album folder of the thumbs we will also have an XML file with the descriptions for the images. We will call that file <strong>desc.xml</strong>. Adding the description for images is not obligatory, i.e. we will just read the ones that are there. The structure of the XML file will be the following:</p>
<pre class="brush:xml">&lt;descriptions&gt;
	&lt;image&gt;
		&lt;name&gt;1.jpg&lt;/name&gt;
		&lt;text&gt;This is a nice description&lt;/text&gt;
	&lt;/image&gt;
	&lt;image&gt;
		&lt;name&gt;2.jpg&lt;/name&gt;
		&lt;text&gt;red!&lt;/text&gt;
	&lt;/image&gt;
	&lt;image&gt;
		&lt;name&gt;3.jpg&lt;/name&gt;
		&lt;text&gt;another one...&lt;/text&gt;
	&lt;/image&gt;
	...
&lt;/descriptions&gt;
</pre>
<p>It is important that we name the images in the name tag correctly.<br />
And also, make sure not to have any other files lying around in those folders.</p>
<h3>The Markup and PHP</h3>
<p>Let&#8217;s take a look at the HTML and also the PHP. We have a simple structure that will be dynamically &#8220;filled&#8221; by our PHP and JavaScript code:</p>
<pre class="brush:xml">&lt;div class="albumbar"&gt;
	&lt;span&gt;Vincent Boiteau's photostream&lt;/span&gt;
	&lt;div id="albumSelect" class="albumSelect"&gt;
		&lt;ul&gt;
			&lt;!-- We will dynamically generate the items --&gt;
			&lt;?php
				$firstAlbum = '';
				$i=0;
				if(file_exists('images')) {
					$files = array_slice(scandir('images'), 2);
					if(count($files)) {
						natcasesort($files);
						foreach($files as $file) {
							if($file != '.' &amp;&amp; $file != '..') {
								if($i===0)
									$firstAlbum = $file;
								else
									echo "&lt;li&gt;&lt;a&gt;$file&lt;/a&gt;&lt;/li&gt;";
								++$i;
							}
						}
					}
				}
			?&gt;
		&lt;/ul&gt;
		&lt;div class="title down"&gt;
			&lt;?php echo $firstAlbum;?&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id="loading"&gt;&lt;/div&gt;
&lt;div id="preview"&gt;
	&lt;div id="imageWrapper"&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id="thumbsWrapper"&gt;
&lt;/div&gt;
&lt;div class="infobar"&gt;
	&lt;span id="description"&gt;&lt;/span&gt;
&lt;/div&gt;
</pre>
<p>The select box items get generated dynamically: we check the sub-folders in the images folder and put all the names in our items. The first album will be &#8220;selected&#8221; by default.</p>
<p style="text-align: center;"><img class="nofancy size-full wp-image-2168  aligncenter" title="FreshSlidingThumbnailsGallery_select" src="http://tympanus.net/codrops/wp-content/uploads/2010/05/FreshSlidingThumbnailsGallery_select.png" alt="" width="424" height="254" /></p>
<p>When we click on one of the items we will call the thumbs.php (inside the ajax folder) from within the JavaScript. We will get back an array (JSON) with all the information that we need to build our thumbnails. Let&#8217;s look at that PHP code first and later we will go through the JS:</p>
<pre class="brush:php">$album 		= $_GET['album'];
$imagesArr	= array();
$i		= 0;

/* read the descriptions xml file */
if(file_exists('../thumbs/'.$album.'/desc.xml')) {
    $xml = simplexml_load_file('../thumbs/'.$album.'/desc.xml');
}
/* read the images from the album and get the
 * description from the XML file:
 */
if(file_exists('../thumbs/'.$album)) {
    $files = array_slice(scandir('../thumbs/'.$album), 2);
    if(count($files)) {
        foreach($files as $file) {
            if($file != '.' &amp;&amp; $file != '..' &amp;&amp;  $file!='desc.xml') {
                if($xml) {
                    $desc = $xml-&gt;xpath('image[name="'.$file.'"]/text');
                    $description = $desc[0];
                    if($description=='')
                        $description = '';
                }
                $imagesArr[] = array('src' =&gt; 'thumbs/'.$album.'/'.$file,
                    'alt'	=&gt; 'images/'.$album.'/'.$file,
                    'desc'	=&gt; $description);
            }
        }
    }
}
$json 		= $imagesArr;
$encoded 	= json_encode($json);
echo $encoded;
unset($encoded);
</pre>
<p>So, we basically get all the thumbnails of the requested album and prepare the information for each img element. The final element that we will then add to our HTML will contain an alt attribute with the full image location as value and a title attribute with the description of the regarding picture as value. The description of the image is taken from the XML file we mentioned before. With an xpath expression we get to the node &#8220;name&#8221; that contains the image name and then we get the text of the description. In the JS we will then say that the description should be the value of the &#8220;title&#8221; attribute.</p>
<p>Now, let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>First, we will add some default styling to the body:</p>
<pre class="brush:css">body{
    font-family:Verdana;
    text-transform:uppercase;
    color:#fff;
    font-size:10px;
    overflow:hidden;
    background-color:#f9f9f9;
}
</pre>
<p>The current background color will be almost white but you can try other colors, it looks really wonderful with some!</p>
<p>Let&#8217;s style the album bar for the title of the page:</p>
<pre class="brush:css">.albumbar{
    height:24px;
    line-height:24px;
    text-align:center;
    position:fixed;
    background-color:#000;
    left:0px;
    width:100%;
    top:0px;
    -moz-box-shadow:-2px 0px 4px #333;
    -webkit-box-shadow:-2px 0px 4px #333;
    box-shadow:-2px 0px 4px #333;
    z-index:11;
}
</pre>
<p>And also the info bar which will contain the description of each image:</p>
<pre class="brush:css">.infobar{
    height:22px;
    line-height:22px;
    text-align:center;
    position:fixed;
    background-color:#000;
    left:0px;
    width:100%;
    bottom:0px;
    -moz-box-shadow:0px -1px 2px #000;
    -webkit-box-shadow:0px -1px 2px #000;
    box-shadow:0px -1px 2px #000;
}
span#description, .albumbar span{
    text-shadow:0px 0px 1px #fff;
    color:#fff;
}
.albumbar span a{
    color:#aaa;
    text-decoration:none;
}
.albumbar span a:hover{
    color:#ddd;
}
</pre>
<p>The info bar and the album bar will be fixed and located at the top and bottom of the page.<br />
The select box and the inner list will be styled as follows:</p>
<pre class="brush:css">.albumSelect{
    height:18px;
    line-height:18px;
    position:absolute;
    right:5px;
    top:2px;
    width:120px;
}
.albumSelect .title{
    color:#f0f0f0;
    z-index:10;
    border:1px solid #444;
    background-color:#555;
    background-repeat:no-repeat;
    background-position:90% 50%;
    cursor:pointer;
    text-align:left;
    text-indent:10px;
    width:100%;
    position:absolute;
    top:0px;
    left:0px;
}
</pre>
<p>The title div will have a little triangle as background image. We define two classes, up and down, that we will then set dynamically depending on if the album list is expanded or not:</p>
<pre class="brush:css">.down{
    background-image:url(../icons/down.png);
}
.up{
    background-image:url(../icons/up.png);
}
</pre>
<p>The unordered list with all the albums will be styled as follows:</p>
<pre class="brush:css">.albumSelect ul {
    list-style:none;
    display:none;
    padding:0px;
    width:100%;
    border:1px solid #444;
    background-color:#555;
    margin:22px 0px 0px 0px;
    -moz-box-shadow:0px 0px 2px #000;
    -webkit-box-shadow:0px 0px 2px #000;
    box-shadow:0px 0px 2px #000;
}
.albumSelect ul li a{
    text-decoration:none;
    cursor:pointer;
    display:block;
    padding:3px 0px;
    color:#ccc;
}
.albumSelect ul li a:hover{
    background-color:#000;
    color:#fff;
}
</pre>
<p>The list is set to display:none in the beginning since we only want it to appear when the user clicks on the triangle to expand it.</p>
<p>The loading container will be set to appear at the center of the page, with just a little bit more to the top since we have the thumbnails bar appearing sometimes. Setting top to 40% gives us what we need:</p>
<pre class="brush:css">#loading{
    display:none;
    width:50px;
    height:50px;
    position:absolute;
    top:40%;
    left:50%;
    margin-left:-24px;
    background:transparent url(../icons/loading.gif) no-repeat top left;
}
</pre>
<p>To make the thumbs bar scrollable by moving the mouse we need to give it a special style. The thumbsWrapper will be positioned absolutely and occupy the width of the window. We set the vertical overflow to hidden because we don&#8217;t want any scroll bar to appear on the right.<br />
The horizontal overflow will be managed in the JavaScript (it will be hidden).</p>
<pre class="brush:css">#thumbsWrapper{
    position: absolute;
    width:100%;
    height:102px;
    overflow-y:hidden;
    background-color:#000;
    bottom:0px;
    left:0px;
    border-top:2px solid #000;
}
</pre>
<p>The thumbsContainer will be the inner div that will have a width equal to the sum of all the thumbnail widths. We will calculate the width dynamically in the JavaScript, so we don&#8217;t define it in the class:</p>
<pre class="brush:css">#thumbsContainer{
    height:79px;
    display:block;
    margin: 0;
}
</pre>
<p>The thumbnail images will have the following style:</p>
<pre class="brush:css">#thumbsWrapper img{
    float:left;
    margin:2px;
    display:block;
    cursor:pointer;
    opacity:0.4;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=40);
}
</pre>
<p>We give them a low opacity value since we want to add a hover effect.</p>
<p>The imageWrapper that contains the full image has the following style:</p>
<pre class="brush:css">#imageWrapper{
    position:relative;
    text-align:center;
    padding-top:30px;
}
</pre>
<p>We add a top padding because we have the album bar at the top of the page. We don&#8217;t want the image to get hidden by it. The margin 0 auto will center the image horizontally:</p>
<pre class="brush:css">#imageWrapper img{
    margin:0 auto;
    -moz-box-shadow:2px 2px 10px #111;
    -webkit-box-shadow:2px 2px 10px #111;
    box-shadow:2px 2px 10px #111;
}
</pre>
<p>We also create a neat box shadow for all modern browsers :)<br />
Some of you might wonder why we set text-align center in the imageWrapper if we have the margin in the image. When we make things appear with the fadeIn function in jQuery, the display of the respective element becomes &#8220;block&#8221;. For that case our &#8220;margin:0 auto&#8221; will center the image. But for the case when we put the first image initially we need the inline centering property which is to give the parent &#8220;text-align:center&#8221;.</p>
<p>And finally, we define the classes for the different cursor types:</p>
<pre class="brush:css">.cursorRight{
.cursorRight{
    cursor:url("../icons/next.cur"), url("icons/next.cur"), default;
}
.cursorLeft{
    cursor:url("../icons/prev.cur"), url("icons/prev.cur"),  default;
}
.cursorPlus{
    cursor:url("../icons/plus.cur"), url("icons/plus.cur"), default;
}
.cursorMinus{
    cursor:url("../icons/minus.cur"), url("icons/minus.cur"), default;
}
</pre>
<p>OK, this is basically a hack and not really nice, but the reason for this ugliness is the browsers&#8217; handling. The first url is the path for FireFox, the second one is for IE and the default value needs to be there again for Firefox. Read more about custom cursors and cross-browser compatibility <a href="http://beradrian.wordpress.com/2008/01/08/cross-browser-custom-css-cursors/" target="_blank">here</a>.</p>
<p>Now, let&#8217;s get to the JavaScript.</p>
<h3>The JavaScript</h3>
<p>Let&#8217;s go step by step through the jQuery code. I will not follow the order like it is in the script but by the usage of the functions. I hope that it will be easier to understand like that.<br />
In our <code>$(function() { }</code> we will add the following JavaScript:</p>
<pre class="brush:js">/* name of the selected album, in the top right combo box */
    var album	= $('#albumSelect div').html();
    /* mode is small or expanded, depending on the picture size  */
    var mode = 'small';
    /* this is the index of the last clicked picture */
    var current = 0;
</pre>
<p>So, we will first declare some variables that we will need later and then we call:</p>
<pre class="brush:js"> buildThumbs();
</pre>
<p>The buildThumbs() function is going to get the current album and generate the images with the accoring source and information:</p>
<pre class="brush:js">function buildThumbs(){
	current=1;
	$('#imageWrapper').empty();
	$('#loading').show();
	$.get('ajax/thumbs.php?album='+album, function(data) {
		var countImages = data.length;
		var count = 0;
		var $tContainer = $('&lt;div/&gt;',{
			id	: 'thumbsContainer',
			style	: 'visibility:hidden;'
		})
		for(var i = 0; i &lt; countImages; ++i){
			try{
				var description = data[i].desc[0];
			}catch(e){
				description='';
			}
			if(description==undefined)
				description='';
			$('&lt;img title="'+description+'" alt="'+data[i].alt+'" height="75" /&gt;').load(function(){
				var $this = $(this);
				$tContainer.append($this);
				++count;
				if(count==1){
					/* load 1 image into container*/
					$('&lt;img id="displayed" style="display:block;" class="cursorPlus"/&gt;').load(function(){
						var $first = $(this);
						$('#loading').hide();
						resize($first,0);
						$('#imageWrapper').append($first);
						$('#description').html($this.attr('title'));
					}).attr('src',$this.attr('alt'));
				}
				if(count == countImages){
					$('#thumbsWrapper').empty().append($tContainer);
					thumbsDim($tContainer);
					makeScrollable($('#thumbsWrapper'),$tContainer,15);
				}
			}).attr('src',data[i].src);
		}
	},'json');
}
</pre>
<p>As we mentioned before, we will be using the thumbs.php file to get the info we need. When we are done building all the thumb images we append it to the thumbsWrapper and determine the size of the container with <code>thumbsDim</code> (line 36):</p>
<pre class="brush:js">/* adjust the size (width) of the scrollable container
- this depends on all its images widths
*/
function thumbsDim($elem){
	var finalW = 0;
	$elem.find('img').each(function(i){
		var $img 		= $(this);
		finalW+=$img.width()+5;
	//plus 5 -&gt; 4 margins + 1 to avoid rounded calculations
	});
	$elem.css('width',finalW+'px').css('visibility','visible');
}
</pre>
<p>Then we use <code>makeScrollable</code> (line 37) to make the thumbnail container scrollable by mouse move:</p>
<pre class="brush:js">//Get our elements for faster access and set overlay width
function makeScrollable($wrapper, $container, contPadding){
	//Get menu width
	var divWidth = $wrapper.width();

	//Remove scrollbars
	$wrapper.css({
		overflow: 'hidden'
	});

	//Find last image container
	var lastLi = $container.find('img:last-child');
	$wrapper.scrollLeft(0);
	//When user move mouse over menu
	$wrapper.unbind('mousemove').bind('mousemove',function(e){

		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + contPadding;

		var left = (e.pageX - $wrapper.offset().left) * (ulWidth-divWidth) / divWidth;
		$wrapper.scrollLeft(left);
	});
}
</pre>
<p>The following function takes care of the click event on a thumbnail and also the hover event:</p>
<pre class="brush:js">/*
clicking on a thumb loads the image
(alt attribute of the thumb is the source of the large image);
mouseover and mouseout for a nice spotlight hover effect
*/
$('#thumbsContainer img').live('click',function(){
	loadPhoto($(this),'cursorPlus');
}).live('mouseover',function(){
	var $this   = $(this);
	$this.stop().animate({
		'opacity':'1.0'
	},200);
}).live('mouseout',function(){
	var $this   = $(this);
	$this.stop().animate({
		'opacity':'0.4'
	},200);
});
</pre>
<p>When a thumbnail is clicked we call the function <code>loadPhoto</code> (and we also pass the current cursor mode):</p>
<pre class="brush:js">/*
loads a picture into the imageWrapper
the image source is in the thumb's alt attribute
*/
function loadPhoto($thumb,cursorClass){
	current		= $thumb.index()+1;
	$('#imageWrapper').empty();
	$('#loading').show();
	$('&lt;img id="displayed" title="'+$thumb.attr('title')+'" class="'+cursorClass+'" style="display:none;"/&gt;').load(function(){
		var $this = $(this);
		$('#loading').hide();
		resize($this,0);
		if(!$('#imageWrapper').find('img').length){
                  $('#imageWrapper').append($this.fadeIn(1000));
                  $('#description').html($this.attr('title'));
            }
	}).attr('src',$thumb.attr('alt'));
}
</pre>
<p>When want to adapt the size of the picture when we resize the window:</p>
<pre class="brush:js">/* when resizing the window resize the picture */
$(window).bind('resize', function() {
	resize($('#displayed'),0);
});
</pre>
<p>The <code>resize</code> function is defined as follows:</p>
<pre class="brush:js">/* function to resize an image based on the windows width and height */
function resize($image, type){
	var widthMargin     = 10
	var heightMargin    = 0;
	if(mode=='expanded')
		heightMargin = 60;
	else if(mode=='small')
		heightMargin = 150;
	//type 1 is animate, type 0 is normal
	var windowH      = $(window).height()-heightMargin;
	var windowW      = $(window).width()-widthMargin;
	var theImage     = new Image();
	theImage.src     = $image.attr("src");
	var imgwidth     = theImage.width;
	var imgheight    = theImage.height;

	if((imgwidth &gt; windowW)||(imgheight &gt; windowH)){
		if(imgwidth &gt; imgheight){
			var newwidth = windowW;
			var ratio = imgwidth / windowW;
			var newheight = imgheight / ratio;
			theImage.height = newheight;
			theImage.width= newwidth;
			if(newheight&gt;windowH){
				var newnewheight = windowH;
				var newratio = newheight/windowH;
				var newnewwidth =newwidth/newratio;
				theImage.width = newnewwidth;
				theImage.height= newnewheight;
			}
		}
		else{
			var newheight = windowH;
			var ratio = imgheight / windowH;
			var newwidth = imgwidth / ratio;
			theImage.height = newheight;
			theImage.width= newwidth;
			if(newwidth&gt;windowW){
				var newnewwidth = windowW;
				var newratio = newwidth/windowW;
				var newnewheight =newheight/newratio;
				theImage.height = newnewheight;
				theImage.width= newnewwidth;
			}
		}
	}
	if((type==1)&amp;&amp;(!$.browser.msie))
		$image.stop(true).animate({
			'width':theImage.width+'px',
			'height':theImage.height+'px'
			},1000);
	else
		$image.css({
			'width':theImage.width+'px',
			'height':theImage.height+'px'
			});
}
</pre>
<p>The <code>heightMargin</code> depends on the mode we are in: if the thumbnails bar is out, we have less space so we reduce the allowed height of the image.</p>
<p>The following functions take care of what happens when we select an album:</p>
<pre class="brush:js">/* Album combo events to open, close,
and select an album from the combo
*/
$('#albumSelect div').bind('click',function(){
	var $this = $(this);
	if($this.is('.up'))
		closeAlbumCombo();
	else if($this.is('.down'))
		openAlbumCombo();
});
$('#albumSelect ul &gt; li').bind('click',function(){
	var $this 	= $(this);
	album 		= $this.find('a').html();
	buildThumbs();
	var $combo = $('#albumSelect div');
	$this.find('a').html($combo.html());
	$combo.html(album);
	closeAlbumCombo();
	orderCombo($this.parent());
});
</pre>
<p>And these are the three functions taking care of our self made combo box:</p>
<pre class="brush:js">//functions to control the albums combos
function closeAlbumCombo(){
	var $combo = $('#albumSelect div');
	$combo.addClass('down').removeClass('up');
	$combo.prev().hide();
}
function openAlbumCombo(){
	var $combo = $('#albumSelect div');
	$combo.addClass('up').removeClass('down');
	$combo.prev().show();
}
function orderCombo($ul){
	var items = $ul.find('li').get();
	items.sort(function(a,b){
		var keyA = $(a).text();
		var keyB = $(b).text();

		if (keyA &lt; keyB) return -1;
		if (keyA &gt; keyB) return 1;
		return 0;
	});
	$.each(items, function(i, li){
		$ul.append(li);
	});
}
</pre>
<p>Now we define what happens when we hover over the main image or when we click on it. Depending on where we hover over the image, we want a certain cursor to appear. For that we check where we are with the mouse and apply the regarding class to the image:</p>
<pre class="brush:js">/*
when hovering the main image change the mouse icons (left,right,plus,minus)
also when clicking on the image, expand it or make it smaller depending on the mode
*/
$('#displayed').live('mousemove',function(e){
	var $this 	= $(this);
	var imageWidth 	= parseFloat($this.css('width'),10);

	var x = e.pageX - $this.offset().left;
	if(x&lt;(imageWidth/3))
		$this.addClass('cursorLeft')
			 .removeClass('cursorPlus cursorRight cursorMinus');
	else if(x&gt;(2*(imageWidth/3)))
		$this.addClass('cursorRight')
			 .removeClass('cursorPlus cursorLeft cursorMinus');
	else{
		if(mode=='expanded'){
			$this.addClass('cursorMinus')
				 .removeClass('cursorLeft cursorRight cursorPlus');
		}
		else if(mode=='small'){
			$this.addClass('cursorPlus')
				 .removeClass('cursorLeft cursorRight cursorMinus');
		}
	}
}).live('click',function(){
	var $this = $(this);
	if(mode=='expanded' &amp;&amp; $this.is('.cursorMinus')){
		mode='small';
		$this.addClass('cursorPlus')
			 .removeClass('cursorLeft cursorRight cursorMinus');
		$('#thumbsWrapper').stop().animate({
			'bottom':'0px'
		},300);
		resize($this,1);
	}
	else if(mode=='small' &amp;&amp; $this.is('.cursorPlus')){
		mode='expanded';
		$this.addClass('cursorMinus')
			 .removeClass('cursorLeft cursorRight cursorPlus');
		$('#thumbsWrapper').stop().animate({
			'bottom':'-85px'
		},300);
		resize($this,1);
	}
	else if($this.is('.cursorRight')){
		var $thumb = $('#thumbsContainer img:nth-child('+parseInt(current+1)+')');
		if($thumb.length){
			++current;
			loadPhoto($thumb,'cursorRight');
		}
	}
	else if($this.is('.cursorLeft')){
		var $thumb = $('#thumbsContainer img:nth-child('+parseInt(current-1)+')');
		if($thumb.length){
			--current;
			loadPhoto($thumb,'cursorLeft');
		}
	}
});
</pre>
<p>When we click on the image, we check which cursor we had, because like that we know which image we have to display next (i.e. the next or the previous one). Our &#8220;current&#8221; variable helps us keep track of which picture we are currently viewing.</p>
<p>And that&#8217;s it! I hope you enjoyed this gigantic tutorial!</p>
<p>Note that in this demo we don&#8217;t use very big images, so the &#8220;zoom in&#8221;/ resize will just show you the full image maximum and never resize the picture beyond its real dimensions. If you use very large images the effect will be a nice experience for users with a large screen.</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGallery/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGallery/FreshSlidingThumbnailsGallery.zip">Download source</a></p>
<p style="clear: both;">We also have a static version of this photo gallery without the album functionality. Check out the <a href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGalleryStatic/" target="_blank">static demo</a> or <a href="http://tympanus.net/Tutorials/FreshSlidingThumbnailsGalleryStatic/FreshSlidingThumbnailsGalleryStatic.zip">download the ZIP file</a>.</p>
<p>We created a mobile version of this gallery: <a href="http://tympanus.net/codrops/2010/05/27/awesome-mobile-image-gallery-web-app/" target="_blank">Awesome Mobile Image Gallery Web App</a></p>
<p style="text-align: center;"><img class="nofancy size-full wp-image-2251  aligncenter" title="previewMobile" src="http://tympanus.net/codrops/wp-content/uploads/2010/05/previewMobile.jpg" alt="" width="395" height="215" /></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
<div class="partner_section_post"><span>Message from Testking</span>Join our online <a href="http://www.testkingsite.com/comptia/N10-004.html">testking N10-004</a> web designing course to learn  how to improve your website using PHP and jQuery. Download  <a href="http://www.testkingsite.com/microsoft/70-640.html">testking 70-640</a> tutorial and  <a href="http://www.testkingsite.com/comptia/220-701.html">testking 220-701</a> design guide to learn how to create fresh sliding thumbnails gallery with jquery.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/05/23/fresh-sliding-thumbnails-gallery-with-jquery-php/feed/</wfw:commentRss>
		<slash:comments>142</slash:comments>
		</item>
		<item>
		<title>Sliding Panel Photo Wall Gallery with jQuery</title>
		<link>http://tympanus.net/codrops/2010/05/14/sliding-panel-photo-wall-gallery-with-jquery/</link>
		<comments>http://tympanus.net/codrops/2010/05/14/sliding-panel-photo-wall-gallery-with-jquery/#comments</comments>
		<pubDate>Fri, 14 May 2010 17:42:54 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slide out]]></category>
		<category><![CDATA[sliding]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2100</guid>
		<description><![CDATA[View demoDownload source Today we will create a stunning full page photo wall gallery. The idea is to have a whole page full of thumbs with a nice light effect when we hover. When an image is clicked, a panel slides up from the bottom revealing the full picture. When clicking on the full image, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/SlidingPanelPhotowallGallery/" target="_blank"><img class="aligncenter size-full wp-image-2101" title="photowall" src="http://tympanus.net/codrops/wp-content/uploads/2010/05/photowall.jpg" alt="" width="580" height="315" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/SlidingPanelPhotowallGallery/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/SlidingPanelPhotowallGallery/SlidingPanelPhotowallGallery.zip">Download source</a></p>
<p>Today we will create a stunning full page photo wall gallery. The idea is to have a whole page full of thumbs with a nice light effect when we hover. When an image is clicked, a panel slides up from the bottom revealing the full picture. When clicking on the full image, the thumbs panel slide back from the bottom. This effect will give the impression that we are stacking the panels on top of each other every time we change the mode. In the full picture view we add some nice transition effect when we browse through the photos.</p>
<p>In addition, we will use a function for resizing the full image, adapting it to the size of the screen. So, when the screen get&#8217;s resized, our image will adapt automatically!</p>
<p>The beautiful images in the demo are from <a href="http://www.flickr.com/photos/2dogs_productions/sets/521679/">Vincent Boiteau&#8217;s photostream</a> on Flickr.</p>
<p>This tutorial will be a little bit more complex than usual, so I will give my best to explain things clearly.</p>
<p>Let&#8217;s get started with the markup.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML structure consists of three main containers: one for the info bar at the bottom of the page, one for the thumbnails and one panel container for the full image:</p>
<pre class="brush:xml"> &lt;div class="infobar"&gt;
	&lt;span id="description"&gt;&lt;/span&gt;
	&lt;span id="loading"&gt;Loading Image&lt;/span&gt;
&lt;/div&gt;
&lt;div id="thumbsWrapper"&gt;
	&lt;div id="content" &gt;
		&lt;img src="thumbs/1.JPG" alt="images/1.JPG" title="something"/&gt;
		&lt;img src="thumbs/2.JPG" alt="images/2.JPG" title="something"/&gt;
		...
		&lt;div class="placeholder"&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id="panel"&gt;
	&lt;div id="wrapper"&gt;
		&lt;a id="prev"&gt;&lt;/a&gt;
		&lt;a id="next"&gt;&lt;/a&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The info bar container has a span for the image description and one for the loading display. The thumbnail wrapper contains a content container for all the small images. The very last element after the thumbnails is a placeholder. We need to add some space to the end because we don&#8217;t want the thumbnails to get covered by the info bar. Since we don&#8217;t want to use any paddings or margins in our containers, we simply add another filler element.</p>
<p>The structure for the panel contains a wrapper for the full image and two navigation items. In our JavaScript function we will add the full size image to this wrapper.</p>
<p>Now, let&#8217;s take a look at the style.</p>
<h3>The CSS</h3>
<p>First, we will define some general style for the page:</p>
<pre class="brush:css">*{
    margin:0;
    padding:0;
}
body{
    background-color:#000;
    font-family:Verdana;
    text-transform:uppercase;
    color:#fff;
    font-size:10px;
    overflow:hidden;
}
</pre>
<p>The body needs to get the property overflow hidden, because we will set the scroll bar for the thumbs view only. If we would add scrolling to the page, the scroll bar would appear when the full image panel slides up. We avoid that by saying that the overflow will be hidden for the body.</p>
<p>The info bar will have a fixed position. We always want it to be visible and at the same place in the page:</p>
<pre class="brush:css">.infobar{
    background-color:#000;
    height:28px;
    line-height:28px;
    right:20px;
    position:fixed;
    bottom:0px;
    left:20px;
    z-index:999999999;
    text-align:center;
    color:#ddd;
    -moz-border-radius:10px 10px 0px 0px;
    -webkit-border-top-left-radius:10px;
    -webkit-border-top-right-radius:10px;
    border-top-left-radius:10px;
    border-top-right-radius:10px;
    text-shadow:0px 0px 1px #ccc;
}
</pre>
<p>We add some border radius for rounded borders. We set the z-index crazily high since we want the element to be always on top. of course you could just use a value like 15 or 50. Just be careful with the other elements that will get a new z-index dynamically in the JS. The highest one of them is 10.</p>
<p>The description and the loading item will have the following style:</p>
<pre class="brush:css">span#description{
    text-shadow:1px 1px 1px #000;
    display:none;
}
span#loading{
    display:none;
    padding-right: 30px;
    background:transparent url(../loading.gif) no-repeat center right;
}
</pre>
<p>The loading item will have a loading image as background.</p>
<p>The thumbs wrapper will have a panel like style. We set it fixed, occupying the whole screen. <strong>Important for the effect is the bottom:0px since we will want the wrapper to come up from the bottom by animating its height.</strong> Again, we set the overflow to hidden, since we just want the content container to have a scroll bar.</p>
<pre class="brush:css">#thumbsWrapper{
    overflow:hidden;
    position:fixed;
    height:100%;
    width:100%;
    left:0px;
    right:0px;
    bottom:0px;
}
</pre>
<p>The content wrapper will also occupy all the page. The vertical scroll bar we set explicitly by saying overflow-y:scroll (auto would be the default value). Initially, we want this container to be invisible because we don&#8217;t want to show the scroll bar while there is nothing on the page during the initial loading time.</p>
<pre class="brush:css">#content{
   position:absolute;
   top:0px;
   height:100%;
   width:100%;
   left:0px;
   background-color:#111;
   overflow-y:scroll;
   display:none;
}
</pre>
<p>The images in the content container will float left and have an opacity of 0.4. The hover function will then increase opacity, giving the whole thing a spotlight effect.</p>
<pre class="brush:css">#content img{
    float:left;
    margin:2px;
    cursor:pointer;
    opacity:0.4;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=40);
}
</pre>
<p>The placeholder will make sure that our thumbs don&#8217;t get covered by the info bar when we are at the bottom of the page:</p>
<pre class="brush:css">.placeholder{
    float:left;
    clear:both;
    width:100%;
    height:30px;
}
</pre>
<p>The panel will have the following style similar to the style of the thumbs wrapper:</p>
<pre class="brush:css">#panel{
    background-color:#222;
    width:100%;
    position:fixed;
    bottom:0px;
    left:0px;
    right:0px;
    height:0px;
    text-align:center;
}
</pre>
<p>Initially, the</p>
<pre class="brush:css">#panel img{
    cursor:pointer;
    position:relative;
    border:1px solid #000;
    -moz-box-shadow:0px 0px 10px #111;
    -webkit-box-shadow:0px 0px 10px #111;
    box-shadow:0px 0px 10px #111;
    display:none;
}
</pre>
<p>We set it to display:none since we will make it appear by fading it in. This will create a nice effect.</p>
<p>The image wrapper be centered horizontally. This we achieve by setting the left and right margins to auto.</p>
<pre class="brush:css">#wrapper{
    position:relative;
    margin:40px auto 0px auto;
}
</pre>
<p>The navigation items will have the following style:</p>
<pre class="brush:css">a#next,
a#prev{
    width:40px;
    height:40px;
    position:fixed;
    cursor:pointer;
    outline:none;
    display:none;
    background:#aaa url(../nav.png) no-repeat top left;
}
a#next:hover, a#prev:hover{
    background-color:#fff;
}
a#next{
    right:0px;
    top:50%;
    margin-top:-20px;
    background-position: 0px 0px;
}
a#prev{
    left:0px;
    top:50%;
    margin-top:-20px;
    background-position: 0px -40px;
}
</pre>
<p>We give the navigation items a fixed position. <strong>To center an absolute or fixed element horizontally (or vertically) you can give it a top (or left) value of 50% and then a negative top (or left) margin of half of its height (or width). </strong>Since the navigation item is 40px high, our top margin is is -20px.</p>
<p>And that was all the style. Now, let&#8217;s take a look at the JavaScript magic:</p>
<h3>The JavaScript</h3>
<p>OK, don&#8217;t scare, it&#8217;s a bit lengthy&#8230; but don&#8217;t worry, most of it is comments and code indention :)<br />
Our main functions fire when we click on a thumb or click on a full image.</p>
<p>When clicking on a thumbnail (line 34) we first show our loading item in the info bar. Then we say to load the respective image (line 40) with the source being the alt attribute of the thumb we clicked (line 92). Everything that is inside of the load function will just be executed after the image is loaded (line 41 to 93). So, we hide the loading item from the info bar, resize the image to fit into the viewport and append the image element to the wrapper. Then we fade it in (line 54) and slide up the panel where we will see the full image and the fading in effect still executing (57 &#8211; 91). We also show the description and the navigation items, and finally we make the thumbs wrapper disappear by setting the height to 0 (line 90). We do that because we want it sliding back from the bottom when we click on the full image.</p>
<p>For the click event on the full image (line 101 to 119) we need to use &#8220;live&#8221; since the img element is not there in the beginning but it is created dynamically. We animate the thumbs wrapper and set the panel to zero height.</p>
<p>The functions for browsing through the full images check which thumb image is the previous or next one and according to that we set the next or previous full image (line 128 to 137). For that we use the navigate function (line 143 to 191).</p>
<p>From line 18 to 26 we say that we want the full size picture to be resized whenever we resize the window. The resize function is defined from line 197 until 237. We also resize the wrapper around the image.</p>
<pre class="brush:js">$(function() {
	/* this is the index of the last clicked picture */
	var current = -1;
	/* number of pictures */
	var totalpictures = $('#content img').size();
	/* speed to animate the panel and the thumbs wrapper */
	var speed 	= 500;

	/* show the content */
	$('#content').show();

	/*
	when the user resizes the browser window,
	the size of the picture being viewed is recalculated;
	 */
	$(window).bind('resize', function() {
		var $picture = $('#wrapper').find('img');
		resize($picture);
	});

	/*
	when hovering a thumb, animate it's opacity
	for a cool effect;
	when clicking on it, we load the corresponding large image;
	the source of the large image is stored as
	the "alt" attribute of the thumb image
	 */
	$('#content &gt; img').hover(function () {
		var $this   = $(this);
		$this.stop().animate({'opacity':'1.0'},200);
	},function () {
		var $this   = $(this);
		$this.stop().animate({'opacity':'0.4'},200);
	}).bind('click',function(){
		var $this   = $(this);

		/* shows the loading icon */
		$('#loading').show();

		$('<img alt="" />').load(function(){
			$('#loading').hide();
			if($('#wrapper').find('img').length) return;
			current 	= $this.index();
			var $theImage   = $(this);
			/*
			After it's loaded we hide the loading icon
			and resize the image, given the window size;
			then we append the image to the wrapper
			*/
			resize($theImage);

			$('#wrapper').append($theImage);
			/* make its opacity animate */
			$theImage.fadeIn(800);

			/* and finally slide up the panel */
			$('#panel').animate({'height':'100%'},speed,function(){
				/*
				if the picture has a description,
				it's stored in the title attribute of the thumb;
				show it if it's not empty
				 */
				var title = $this.attr('title');
				if(title != '')
					$('#description').html(title).show();
				else
					$('#description').empty().hide();

				/*
				if our picture is the first one,
				don't show the "previous button"
				for the slideshow navigation;
				if our picture is the last one,
				don't show the "next button"
				for the slideshow navigation
				 */
				if(current==0)
					$('#prev').hide();
				else
					$('#prev').fadeIn();
				if(current==parseInt(totalpictures-1))
					$('#next').hide();
				else
					$('#next').fadeIn();
				/*
				we set the z-index and height of the thumbs wrapper
				to 0, because we want to slide it up afterwards,
				when the user clicks the large image
				 */
				$('#thumbsWrapper').css({'z-index':'0','height':'0px'});
			});
		}).attr('src', $this.attr('alt'));
	});

	/*
	when hovering a large image,
	we want to slide up the thumbs wrapper again,
	and reset the panel (like it was initially);
	this includes removing the large image element
	 */
	$('#wrapper &gt; img').live('click',function(){
		$this = $(this);
		$('#description').empty().hide();

		$('#thumbsWrapper').css('z-index','10')
		.stop()
		.animate({'height':'100%'},speed,function(){
			var $theWrapper = $(this);
			$('#panel').css('height','0px');
			$theWrapper.css('z-index','0');
			/*
			remove the large image element
			and the navigation buttons
			 */
			$this.remove();
			$('#prev').hide();
			$('#next').hide();
		});
	});

	/*
	when we are viewing a large image,
	if we navigate to the right/left we need to know
	which image is the corresponding neighbour.
	we know the index of the current picture (current),
	so we can easily get to the neighbour:
	 */
	$('#next').bind('click',function(){
		var $this           = $(this);
		var $nextimage 		= $('#content img:nth-child('+parseInt(current+2)+')');
		navigate($nextimage,'right');
	});
	$('#prev').bind('click',function(){
		var $this           = $(this);
		var $previmage 		= $('#content img:nth-child('+parseInt(current)+')');
		navigate($previmage,'left');
	});

	/*
	given the next or previous image to show,
	and the direction, it loads a new image in the panel.
	 */
	function navigate($nextimage,dir){
		/*
		if we are at the end/beginning
		then there's no next/previous
		 */
		if(dir=='left' &amp;&amp; current==0)
			return;
		if(dir=='right' &amp;&amp; current==parseInt(totalpictures-1))
			return;
		$('#loading').show();
		$('<img alt="" />').load(function(){
			var $theImage = $(this);
			$('#loading').hide();
			$('#description').empty().fadeOut();

			$('#wrapper img').stop().fadeOut(500,function(){
				var $this = $(this);

				$this.remove();
				resize($theImage);

				$('#wrapper').append($theImage.show());
				$theImage.stop().fadeIn(800);

				var title = $nextimage.attr('title');
				if(title != ''){
					$('#description').html(title).show();
				}
				else
					$('#description').empty().hide();

				if(current==0)
					$('#prev').hide();
				else
					$('#prev').show();
				if(current==parseInt(totalpictures-1))
					$('#next').hide();
				else
					$('#next').show();
			});
			/*
			increase or decrease the current variable
			 */
			if(dir=='right')
				++current;
			else if(dir=='left')
				--current;
		}).attr('src', $nextimage.attr('alt'));
	}

	/*
	resizes an image given the window size,
	considering the margin values
	 */
	function resize($image){
		var windowH      = $(window).height()-100;
		var windowW      = $(window).width()-80;
		var theImage     = new Image();
		theImage.src     = $image.attr("src");
		var imgwidth     = theImage.width;
		var imgheight    = theImage.height;

		if((imgwidth &gt; windowW)||(imgheight &gt; windowH)){
			if(imgwidth &gt; imgheight){
				var newwidth = windowW;
				var ratio = imgwidth / windowW;
				var newheight = imgheight / ratio;
				theImage.height = newheight;
				theImage.width= newwidth;
				if(newheight&gt;windowH){
					var newnewheight = windowH;
					var newratio = newheight/windowH;
					var newnewwidth =newwidth/newratio;
					theImage.width = newnewwidth;
					theImage.height= newnewheight;
				}
			}
			else{
				var newheight = windowH;
				var ratio = imgheight / windowH;
				var newwidth = imgwidth / ratio;
				theImage.height = newheight;
				theImage.width= newwidth;
				if(newwidth&gt;windowW){
					var newnewwidth = windowW;
					var newratio = newwidth/windowW;
					var newnewheight =newheight/newratio;
					theImage.height = newnewheight;
					theImage.width= newnewwidth;
				}
			}
		}
		$image.css({'width':theImage.width+'px','height':theImage.height+'px'});
	}
});
</pre>
<p>For further details, check the comments in the code, they describe what is done in the moment.</p>
<p>And that&#8217;s it! I hope you enjoyed the tutorial and the result!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/SlidingPanelPhotowallGallery/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/SlidingPanelPhotowallGallery/SlidingPanelPhotowallGallery.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
<div class="partner_section_post"><span>Message from Testking</span>Learn useful web  design applications with <a href="http://www.testkingsite.com/cisco/CCNA.html">testking ccna</a> course and become expert using <a href="http://www.testkingsite.com/cisco/CCNP.html">testking ccnp</a> design tutorials and <a href="http://www.testkingsite.com/cisco/CCIE.html">testking ccie</a> design recourses.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/05/14/sliding-panel-photo-wall-gallery-with-jquery/feed/</wfw:commentRss>
		<slash:comments>117</slash:comments>
		</item>
		<item>
		<title>Elegant Accordion with jQuery and CSS3</title>
		<link>http://tympanus.net/codrops/2010/04/26/elegant-accordion-with-jquery-and-css3/</link>
		<comments>http://tympanus.net/codrops/2010/04/26/elegant-accordion-with-jquery-and-css3/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 15:10:37 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=1814</guid>
		<description><![CDATA[View demoDownload source Today we will create an elegant accordion for content. The idea is to have some vertical accordion tabs that slide out when hovering. We will add some CSS3 properties to enhance the looks. Ok, let&#8217;s start with the markup. The Markup The HTML will consist of a list where each accordion tab [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/ElegantAccordion/" target="_blank"><img class="aligncenter size-full wp-image-1815" title="elegantacc" src="http://tympanus.net/codrops/wp-content/uploads/2010/04/elegantacc.png" alt="" width="580" height="362" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/ElegantAccordion/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ElegantAccordion/ElegantAccordion.zip">Download source</a></p>
<p>Today we will create an elegant accordion for content. The idea is to have some vertical accordion tabs that slide out when hovering. We will add some CSS3 properties to enhance the looks.<br />
Ok, let&#8217;s start with the markup.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The HTML will consist of a list where each accordion tab is a list element. Inside of the list element we will have a heading that disappears when we hover. Also, there will an element for the white background gradient and a div for the description. Here is the markup with just one list element:</p>
<pre class="brush:xml">&lt;ul class="accordion" id="accordion"&gt;
	&lt;li class="bg1"&gt;
		&lt;div class="heading"&gt;Heading&lt;/div&gt;
		&lt;div class="bgDescription"&gt;&lt;/div&gt;
		&lt;div class="description"&gt;
			&lt;h2&gt;Heading&lt;/h2&gt;
			&lt;p&gt;Some descriptive text&lt;/p&gt;
			&lt;a href="#"&gt;more ?&lt;/a&gt;
		&lt;/div&gt;
	&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>The other list elements will have the classes bg2, bg3 and bg4. The unordered list gets a class and an id since we want to address it later in the JavaScript. Of course, we would not really need the class but instead,  style the element using #accordion in our style sheet. But this is a good way to keep things separate.</p>
<h3>The CSS</h3>
<p>The style for the list will look as follows:</p>
<pre class="brush:css">ul.accordion{
    list-style:none;
    position:absolute;
    right:80px;
    top:0px;
    font-family: Cambria, serif;
    font-size: 16px;
    font-style: italic;
    line-height: 1.5em;
}
</pre>
<p>The list elements will each have a different background image, so we will first define the general style properties for every list element and then the single classes with the background images:</p>
<pre class="brush:css">ul.accordion li{
    float:right;
    width:115px;
    height:480px;
    display:block;
    border-right:2px solid #fff;
    border-bottom:2px solid #fff;
    background-color:#fff;
    background-repeat:no-repeat;
    background-position:center center;
    position:relative;
    overflow:hidden;
    cursor:pointer;
    -moz-box-shadow:1px 3px 15px #555;
    -webkit-box-shadow:1px 3px 15px #555;
    box-shadow:1px 3px 15px #555;
}
ul.accordion li.bg1{
    background-image:url(../images/1.jpg);
}
ul.accordion li.bg2{
    background-image:url(../images/2.jpg);
}
ul.accordion li.bg3{
    background-image:url(../images/3.jpg);
}
ul.accordion li.bg4{
    background-image:url(../images/4.jpg);
}
</pre>
<p>Note, that the box shadow will not work in IE.<br />
The initial width of each item will be 115 pixels. We will alter this in the JavaScript hover function (to 480px).<br />
The border that we give each list element can only be applied to one side, otherwise we would have a double border in between the items and just a single one at the outer limits. So, we need to define a class for a left border, that we will apply to the last list element (they are floating right, so the order is reversed):</p>
<pre class="brush:css">ul.accordion li.bleft{
    border-left:2px solid #fff;
}
</pre>
<p>Now, we want a nice looking header with a white semi-transparent background for each list item when in the normal &#8220;closed&#8221; state:</p>
<pre class="brush:css">ul.accordion li .heading{
    background-color:#fff;
    padding:10px;
    margin-top:60px;
    opacity:0.9;
    text-transform:uppercase;
    font-style:normal;
    font-weight:bold;
    letter-spacing:1px;
    font-size:14px;
    color:#444;
    text-align:center;
    text-shadow:-1px -1px 1px #ccc;
}
</pre>
<p>The div that contains the description will have the following style:</p>
<pre class="brush:css">ul.accordion li .description{
    position:absolute;
    width:480px;
    height:175px;
    bottom:0px;
    left:0px;
    display:none;
}
</pre>
<p>We set it to display:none initially, since we only want it to appear when hovering. And here is, how we style the inner elements:</p>
<pre class="brush:css">ul.accordion li .description h2{
    text-transform:uppercase;
    font-style:normal;
    font-weight:bold;
    letter-spacing:1px;
    font-size:45px;
    color:#444;
    text-align:left;
    margin:0px 0px 15px 20px;
    text-shadow:-1px -1px 1px #ccc;
}
ul.accordion li .description p{
    line-height:14px;
    margin:10px 22px;
    font-family: "Trebuchet MS", sans-serif;
    font-size: 12px;
    font-style: italic;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.6em;
}
ul.accordion li .description a{
    position:absolute;
    bottom:5px;
    left:20px;
    text-transform:uppercase;
    font-style:normal;
    font-size:11px;
    text-decoration:none;
    color:#888;
}
ul.accordion li .description a:hover{
    color:#333;
    text-decoration:underline;
}
</pre>
<p>The only style missing is the one for the gradient element:</p>
<pre class="brush:css">ul.accordion li .bgDescription{
    background:transparent url(../images/bgDescription.png) repeat-x top left;
    height:340px;
    position:absolute;
    bottom:0px;
    left:0px;
    width:100%;
    display:none;
}
</pre>
<p>The image that we are repeating is a gradient that goes from white to transparent. This will give a nice effect when we make this div slide in from the bottom.</p>
<p>Let&#8217;s add some magic!</p>
<h3>The JavaScript</h3>
<p>First, we include the jQuery library before the body end tag:</p>
<pre class="brush:js">&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt;
</pre>
<p>Now, we will add a function that makes a list element slide out when hovering over it. This will be achieved by animating the increase of the width to 480 pixels. Then the top heading should fade out while the gradient (css class &#8220;bgDescription&#8221;) and the description appear:</p>
<pre class="brush:js">&lt;script type="text/javascript"&gt;
$(function() {
    $('#accordion &gt; li').hover(
        function () {
            var $this = $(this);
            $this.stop().animate({'width':'480px'},500);
            $('.heading',$this).stop(true,true).fadeOut();
            $('.bgDescription',$this).stop(true,true).slideDown(500);
            $('.description',$this).stop(true,true).fadeIn();
        },
        function () {
            var $this = $(this);
            $this.stop().animate({'width':'115px'},1000);
            $('.heading',$this).stop(true,true).fadeIn();
            $('.description',$this).stop(true,true).fadeOut(500);
            $('.bgDescription',$this).stop(true,true).slideUp(700);
        }
    );
});
&lt;/script&gt;
</pre>
<p>The first function inside of <strong>$(&#8216;#accordion &gt; li&#8217;).hover</strong> is the function triggered when the mouse moves over the respective element and the second function gets triggered when moving the mouse out again. Here we reverse the actions and also add some timing to it, so that the elements disappear smoothly.</p>
<p>And that&#8217;s all! I hope you enjoyed this tutorial and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/ElegantAccordion/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ElegantAccordion/ElegantAccordion.zip">Download source</a></p>
<p><!-- wp_ad_camp_1 --></p>
<div class="partner_section_post"><span>Message from Testking</span>We offer online <a href="http://www.pass4sure.com/Oracle-index.html">oracle training</a> program to help you pass <a href="http://www.pass4sure.com/PMI-Certifications.html">pmi certifications</a> on time.  Learn about jquery and css3 using <a href="http://www.pass4sure.com/CompTIA-Security-plus.html">security+</a> tutorial and other resources.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/04/26/elegant-accordion-with-jquery-and-css3/feed/</wfw:commentRss>
		<slash:comments>74</slash:comments>
		</item>
		<item>
		<title>End of Page Slide Out Box with jQuery</title>
		<link>http://tympanus.net/codrops/2010/04/13/end-of-page-slide-out-box/</link>
		<comments>http://tympanus.net/codrops/2010/04/13/end-of-page-slide-out-box/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 15:22:32 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=1766</guid>
		<description><![CDATA[View demoDownload source The other day I was reading an article in the NYTimes and I really liked the box that slides out from the right when you are reading the last part of the article. It shows another article from the same category and I thought that it might be something interesting for any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/EndPageSlideOutBox/" target="_blank"><img class="aligncenter size-full wp-image-1786" title="endofpage" src="http://tympanus.net/codrops/wp-content/uploads/2010/04/endofpage.png" alt="" width="580" height="362" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/EndPageSlideOutBox/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/EndPageSlideOutBox/EndPageSlideOutBox.zip">Download source</a></p>
<p>The other day I was reading an article in the <a href="http://www.nytimes.com/">NYTimes</a> and I really liked the box that slides out from the right when you are reading the last part of the article. It shows another article from the same category and I thought that it might be something interesting for any blog or website.</p>
<p>The idea is to have an element in the page (here it is in the last paragraph) that triggers the box to appear. You could, for example, use this to show a related article or to explain a certain term you are using in your post.</p>
<p>Ok, let&#8217;s start!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>First, we need a paragraph somewhere in the page with the id &#8220;last&#8221;:</p>
<pre class="brush:xml">&lt;p id="last"&gt;
    Some paragraph text
&lt;/p&gt;
</pre>
<p>Then, we need the following html for the box:</p>
<pre class="brush:xml">&lt;div id="slidebox"&gt;
	&lt;a class="close"&gt;&lt;/a&gt;
	&lt;p&gt;More in Technology &amp; Science (4 of 23 articles)&lt;/p&gt;
	&lt;h2&gt;The Social Impact of Scientific Research and new Technologies&lt;/h2&gt;
	&lt;a class="more"&gt;Read More »&lt;/a&gt;
&lt;/div&gt;
</pre>
<p>The link element with the class &#8220;close&#8221; will give the user the option to close the box and it will not appear again.</p>
<h3>The CSS</h3>
<p>Ok, let&#8217;s give some style to the box in a NYTimes manner:</p>
<pre class="brush:css">#slidebox{
    width:400px;
    height:100px;
    padding:10px;
    background-color:#fff;
    border-top:3px solid #E28409;
    position:fixed;
    bottom:0px;
    right:-430px;
    -moz-box-shadow:-2px 0px 5px #aaa;
    -webkit-box-shadow:-2px 0px 5px #aaa;
    box-shadow:-2px 0px 5px #aaa;
}
</pre>
<p>We give the box a fixed position, so that it follows the user while he is scrolling. The initial right value will make the box be hidden; we will make it slide out with some jQuery.</p>
<p>The box will have a nice CSS3 box shadow, and no, that will not work in IE browsers (except IE9, probably).<br />
Check out this entry on CSS3.info if you want to see how to create a shadow: <a href="http://www.css3.info/preview/box-shadow/">Box-shadow, one of CSS3’s best new features</a></p>
<p>The text elements and the more link will have the following style:</p>
<pre class="brush:css">#slidebox p, a.more{
    font-size:11px;
    text-transform:uppercase;
    font-family: Arial,Helvetica,sans-serif;
    letter-spacing:1px;
    color:#555;
}
a.more{
    cursor:pointer;
    color:#E28409;
}
a.more:hover{
    text-decoration:underline;
}
#slidebox h2{
    color:#E28409;
    font-size:18px;
    margin:10px 20px 10px 0px;
}
</pre>
<p>You might want to adapt the style of these elements to fit with you website. The style of the little closing cross looks as follows:</p>
<pre class="brush:css">a.close{
    background:transparent url(../images/close.gif) no-repeat top left;
    width:13px;
    height:13px;
    position:absolute;
    cursor:pointer;
    top:10px;
    right:10px;
}
a.close:hover{
    background-position:0px -13px;
}
</pre>
<p>Now, let&#8217;s add some JavaScript for the effect.</p>
<h3>The JavaScript</h3>
<p>First, we include the jQuery library before the body end tag:</p>
<pre class="brush:js">&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt;
</pre>
<p>Then we will add two functions. One is to determine if we reached the trigger element while scrolling and to make the box slide out if so. The other function makes the box disappear when clicking on the little closing cross. Add this after the inclusion of the jQuery library and before the body end tag:</p>
<pre class="brush:js">&lt;script type="text/javascript"&gt;
$(function() {
	$(window).scroll(function(){
		var distanceTop = $('#last').offset().top - $(window).height();

		if  ($(window).scrollTop() &gt; distanceTop)
			$('#slidebox').animate({'right':'0px'},300);
		else
			$('#slidebox').stop(true).animate({'right':'-430px'},100);
	});

	$('#slidebox .close').bind('click',function(){
		$(this).parent().remove();
	});
});
&lt;/script&gt;
</pre>
<p>And that&#8217;s it! I hope you liked the tutorial and can make some use of it!</p>
<p>Enjoy!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/EndPageSlideOutBox/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/EndPageSlideOutBox/EndPageSlideOutBox.zip">Download source</a></p>
<p><!-- wp_ad_camp_1 --></p>
<div class="partner_section_post"><span>Message from Testking</span>Get professional <a href="http://www.pass4sure.com/640-863.html">640-863</a> training to learn jQuery plugins and other web applications to create successful websites. We  offer  self paced <a href="http://www.pass4sure.com/CCIE-Security.html">ccie security</a> tutorial and <a href="http://www.pass4sure.com/CCIE-LAB.html">ccie lab</a> to  make  your  learning process easy for you.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/04/13/end-of-page-slide-out-box/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  tympanus.net/codrops/tag/slide-out/feed/ ) in 0.36987 seconds, on May 23rd, 2012 at 11:55 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 24th, 2012 at 12:55 am UTC -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Quick Cache Is Fully Functional :-) ... A Quick Cache file was just served for (  tympanus.net/codrops/tag/slide-out/feed/ ) in 0.00049 seconds, on May 24th, 2012 at 12:54 am UTC. -->
