<?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; grunge</title>
	<atom:link href="http://tympanus.net/codrops/tag/grunge/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>Grungy Random Rotation Menu with jQuery and CSS3</title>
		<link>http://tympanus.net/codrops/2010/02/24/grungy-random-rotation-menu-with-jquery-and-css3/</link>
		<comments>http://tympanus.net/codrops/2010/02/24/grungy-random-rotation-menu-with-jquery-and-css3/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 16:37:26 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[grunge]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[rotation]]></category>
		<category><![CDATA[slide out]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=1605</guid>
		<description><![CDATA[View demoDownload source In this tutorial we are going to create a great menu with some content area that slides out. We use the grunge style because we want it to look a bit messy: the menu items are going to have a random rotation using the CSS3 property &#8220;transform&#8221;. So, when we load the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tympanus.net/Tutorials/GrungyRandomSlideOut/" target="_blank"><img class="aligncenter size-full wp-image-1608" title="GrungeSlideOut" src="http://tympanus.net/codrops/wp-content/uploads/2010/02/GrungeSlideOut.png" alt="GrungeSlideOut" width="580" height="283" /></a></p>
<p><a class="demo" href="http://www.tympanus.net/Tutorials/GrungyRandomSlideOut/" target="_blank">View demo</a><a class="download" href="http://www.tympanus.net/Tutorials/GrungyRandomSlideOut/GrungyRandomSlideOut.zip">Download source</a></p>
<p>In this tutorial we are going to create a great menu with some content area that slides out. We use the grunge style because we want it to look a bit messy: the menu items are going to have a random rotation using the CSS3 property &#8220;transform&#8221;. So, when we load the page each menu item will be positioned differently, giving a random and creative look to this grunge page.</p>
<p>The content area is going to be visible in the beginning, but slide out and back in everytime another menu item is clicked. Also, we will be randomizing the rotation degree of the content area.</p>
<p>Please note that the rotation effect will not work in IE or any other browers that does not support standa..ehm CSS3 yet.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Resources</h3>
<p>Let&#8217;s first start with the images that we need for this tutorial. You can find some nice paper backgrounds here (please check the rights of each download source):</p>
<p><a href="http://www.creativecloseup.com/30-great-free-paper-backgrounds-and-textures" target="_blank">http://www.creativecloseup.com/30-great-free-paper-backgrounds-and-textures</a></p>
<p>I used the first one which can also be directly found here:</p>
<p><a href="http://www.flickr.com/photos/playingwithpsp/2583644089/sizes/o/">http://www.flickr.com/photos/playingwithpsp/2583644089/sizes/o/</a></p>
<p>And background image for the menu items can be found <a href="http://tympanus.net/Tutorials/GrungyRandomSlideOut/item.png" target="_blank">here</a>.</p>
<h3>The Markup</h3>
<p>We will start with the markup of the content area:</p>
<pre class="brush:xml">&lt;div id="content"&gt;
	&lt;div id="home" class="text"&gt;
		&lt;!-- Write your content here --&gt;
	&lt;/div&gt;
	&lt;div id="about" class="text" style="display:none;"&gt;
		&lt;!-- Write your content here --&gt;
	&lt;/div&gt;
	&lt;!-- Other content items --&gt;
&lt;/div&gt;</pre>
<p>The menu will have the following markup:</p>
<pre class="brush:xml">&lt;ul id="navigation"&gt;
	&lt;li class="home"&gt;&lt;a title="Home"&gt;Home&lt;/a&gt;&lt;/li&gt;
	&lt;li class="about"&gt;&lt;a title="About"&gt;About&lt;/a&gt;&lt;/li&gt;
	&lt;li class="search"&gt;&lt;a title="Search"&gt;Search&lt;/a&gt;&lt;/li&gt;
	&lt;li class="photos"&gt;&lt;a title="Photos"&gt;Photos&lt;/a&gt;&lt;/li&gt;
	&lt;li class="contact"&gt;&lt;a title="Contact"&gt;Contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<h3>The CSS</h3>
<p>The content div and the inner element will have the following style:</p>
<pre class="brush:css">#content{
    width:824px;
    height:600px;
    margin:-200px auto 0px auto;
    background:transparent url(bg.gif) no-repeat bottom left;
}
#content h1{
    color:#7F6137;
    text-shadow:1px 1px 1px #fff;
}
#content p{
    margin:20px;
    width:600px;
}
#content .text{
    padding:300px 0px 0px 100px;
}</pre>
<p>So, the content area is going to have the paper background and the top is going to be hidden. That we achive by setting the margin to a negative value: we full the content area up outside of the visible window.</p>
<p>The menu is going to have the following styling:</p>
<pre class="brush:css">ul#navigation {
    position: fixed;
    margin: 0px;
    padding: 0px;
    top: 0px;
    right: 200px;
    list-style: none;
    z-index:999999;
}
ul#navigation li {
    display:inline;
    float:left;
    width:100px;
    margin-left:1px;
}
ul#navigation li a {
    display: block;
    font-weight: bold;
    text-shadow: 1px 1px 1px #fff;
    float: left;
    width: 100px;
    height: 35px;
    color: #603d05;
    background: transparent url(item.png) no-repeat bottom right;
    text-decoration:none;
    text-align: center;
    padding-top: 80px;
    margin-top: -40px;
    cursor: pointer;
}</pre>
<p>Since we will make the menu items slide out a bit when we hover over them, we initially set the top margin to a negative value. The navigation list itself will be fixed, which means that even if you have more content to scroll, it will always be at the top of the page.</p>
<p><strong>In browsers where the scroll just appears when the content gets bigger, you might want to set some initial height of the body in order to avoid the menu moving.</strong></p>
<p>Let&#8217;s add some magic!</p>
<h3>The JavaScript</h3>
<p>Here is the JavaScript function that will add all the magic:</p>
<pre class="brush:js">$(function() {
	var d=300;
	$('#navigation a').each(function(){
		var $this = $(this);
		var r=Math.floor(Math.random()*41)-20;
		$this.css({
			'-moz-transform':'rotate('+r+'deg)',
			'-webkit-transform':'rotate('+r+'deg)',
			'transform':'rotate('+r+'deg)'
			});
		$('#content').css({
			'-moz-transform':'rotate('+r+'deg)',
			'-webkit-transform':'rotate('+r+'deg)',
			'transform':'rotate('+r+'deg)'
			});
		$this.stop().animate({
			'marginTop':'-70px'
		},d+=150);
	});
	$('#navigation &gt; li').hover(
		function () {
			var $this = $(this);
			$('a',$this).stop().animate({
				'marginTop':'-40px'
			},200);
		},
		function () {
			var $this = $(this);
			$('a',$this).stop().animate({
				'marginTop':'-70px'
			},200);
		}
	).click(function(){
		var $this = $(this);
		var name = this.className;
		$('#content').animate({marginTop:-600}, 300,function(){
			var $this = $(this);
			var r=Math.floor(Math.random()*41)-20;
			$this.css({
				'-moz-transform':'rotate('+r+'deg)',
				'-webkit-transform':'rotate('+r+'deg)',
				'transform':'rotate('+r+'deg)'
				});
			$('#content div').hide();
			$('#'+name).show();
			$this.animate({marginTop:-200}, 300);
		})
	});
});</pre>
<p>In the beginning we generate a random number from -20 to 20 which will be our degree of rotation. Each menu item and the content will initially be rotated randomly. When we hover over the menu items, they will slide out a bit, and slide back in when the mouse is moved out.</p>
<p>Whenever we click on one of the menu links, the according inner content element gets shown. Also, the content area slides in and back out while changing it&#8217;s degree of rotation.</p>
<p>And that&#8217;s it? Absolutely!</p>
<p>By the way, it&#8217;s rendered very nicely in Chrome!</p>
<p>Enjoy it!</p>
<p><a class="demo" href="http://www.tympanus.net/Tutorials/GrungyRandomSlideOut/" target="_blank">View demo</a><a class="download" href="http://www.tympanus.net/Tutorials/GrungyRandomSlideOut/GrungyRandomSlideOut.zip">Download source</a></p>
<p><!-- wp_ad_camp_1 --></p>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/02/24/grungy-random-rotation-menu-with-jquery-and-css3/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  tympanus.net/codrops/tag/grunge/feed/ ) in 0.20485 seconds, on May 23rd, 2012 at 2:26 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 23rd, 2012 at 3:26 pm UTC -->
