<?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>Xguiden &#187; JavaScript</title>
	<atom:link href="http://xguiden.dk/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://xguiden.dk</link>
	<description>Dine guides findes her</description>
	<lastBuildDate>Sat, 13 Mar 2010 16:37:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Awesome CSS+JS form styling</title>
		<link>http://xguiden.dk/2010/03/10/awesome-cssjs-form-styling/</link>
		<comments>http://xguiden.dk/2010/03/10/awesome-cssjs-form-styling/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:14:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[auto login]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[input type text]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript library]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[open source project]]></category>
		<category><![CDATA[scenarios]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Transparent]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5558</guid>
		<description><![CDATA[Sexy CSS+JS Form

I was working on our new open source project that i think you will like and I was working on the registration page. This is what I got in the end and i will walk you trough the process with me. This new tutorial is about styling the forms of your website, I [...]]]></description>
			<content:encoded><![CDATA[<div><a rel="attachment wp-att-312" href="http://xguiden.dk/?attachment_id=312"><img class="size-medium wp-image-312" src="http://blog.ajaxmasters.com/wp-content/uploads/2010/03/sexy-form-300x214.png" alt="Sexy CSS Form" width="300" height="214" /></a>Sexy CSS+JS Form</p>
</div>
<p>I was working on our new open source project that i think you will like and I was working on the registration page. This is what I got in the end and i will walk you trough the process with me. This new tutorial is about styling the forms of your website, I find it very good looking and very simple to implement. We will use simple CSS and some JavaScript.</p>
<p>Usually for inserting text into the inputs or our forms we set the value attribute with the text and then use javascript to check for different scenarios for doing some fancy things. This is different we will use labels to fill the text and move them under the inputs and then just do our magic with JS.</p>
<p>The JavaScript library that we will use to create this effect for our forms is <a href="http://jquery.com" target="_blank">Jquery</a></p>
<p><strong>1. Creating the markup!</strong></p>
<pre>            &lt;div id="login"&gt;
                &lt;div class="sayit"&gt;Log In:&lt;/div&gt;
                &lt;form action="javascript:void(0)" onsubmit="login()" autocomplete="off"&gt;
                    &lt;label for="username"&gt;Username&lt;/label&gt;
                    &lt;input type="text" id="username"/&gt;
                    &lt;label for="password"&gt;Password&lt;/label&gt;
                    &lt;input type="password" id="password"/&gt;
                    &lt;input type="submit" class="medium button green" value="Log me In"/&gt;
                &lt;/form&gt;
            &lt;/div&gt;</pre>
<p>The above code is our markup and as you can see is very simple and it can be changed as you like because the code that we will use for checking for different scenarios in javascript will work without necessary classes or ids. We have 2 inputs and 2 labels, one is password one is text and we can work with these ones, you can add as many as you like.</p>
<p>Now let’s style these bastards! <img class="wp-smiley" src="http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/smile-big.png" alt=":D" /></p>
<p><strong>2. Use CSS to style the form elements!</strong></p>
<pre>input[type=text],input[type=password]{padding: 5px 10px; background-color: transparent;	position: relative; z-index: 2;}
label{position: absolute; z-index: 1;-webkit-transition: opacity 0.15s linear; color: #bababa; background-color: #FFFFFF; }

#login{width: 290px; margin: 0 auto;}
#login input[type=text],#login input[type=password]{width:270px; margin: 5px 0; font-size: 24px; font-weight: bold; border: 1px solid #ccc; -moz-border-radius:5px; -webkit-border-radius:5px; color: #595959;}
#login label{font-size: 24px; margin: 14px 10px;}

#login .sayit{font-size:24px; color: #595959; font-style: italic; padding-bottom: 5px;}</pre>
<p>What we did here is make the label absolute so it will go under the input. This is important you will have to place the label before the input so remember this! The input will have a position relative and a z-index of 2 so we can be sure it will land above the label. Next we define the login div by using his id(<em>#login</em>). We use CSS3 for creating the round borders for the input and style the label by setting a big font-size to fit the input. The rest is pretty obvious, if you have trouble understanding this then let us know in the comments.</p>
<p><strong>3. Make everything move with JS!</strong></p>
<pre>$(document).ready(function(){
    $.string(String.prototype);
    $("input,textarea").each(function (type) {
        $(this).focus(function () {
            if($(this).val().blank())
                $(this).prev("label").fadeTo('fast',0.45);
        });

        $(this).keypress(function () {
            $(this).prev("label").fadeTo('fast',0);
        });

        $(this).blur(function () {
            if($(this).val().blank()){
                $(this).prev("label").fadeTo('fast',1);
            }
        });
    });
});</pre>
<p>We use here jQuery of course that we add using the google api like this:</p>
<pre>        &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;</pre>
<p>And one plugin that I use to extend the jQuery string properties and that is <a href="http://stilldesigning.com/dotstring/">$.string plugin</a>. After we do that we create the above code and we assign to input and textarea elements a focus, keypress and blur actions. We use the focus action to lower the labels opacity to 45% then on keypress we just hide it for good. Then on blur we check to see if anything was written in our sexy element and if not then we fade the label back to 100%. This is kind of everything we do here, pretty simple. <img class="wp-smiley" src="http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/smile.png" alt=":)" /></p>
<p><strong>4. Showing of a demo and download source</strong></p>
<p>I’ve set up a demo here: <a href="http://tutorials.ajaxmasters.com/sexy-form/" target="_blank"><strong><em>DEMO</em></strong></a></p>
<p>The source code you can either pick it from the demo page or from here: <a href="http://tutorials.ajaxmasters.com/sexy-form/source.zip"><strong><em>SOURCE</em></strong></a></p>
<p><strong>5. Wrapping up!</strong></p>
<p>So here is our nice form styling that you can use on your website and that can be done very easily. Feel free to leave us comments and suggestions. <strong>Thanks a lot!</strong></p>
<p>Have fun coding!<img src="http://feeds.feedburner.com/~r/AjaxmastersBlogRss/~4/0J4er0tKB4Q" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/ajax/" title="AJAX" rel="tag">AJAX</a>, <a href="http://xguiden.dk/tag/attribute/" title="attribute" rel="tag">attribute</a>, <a href="http://xguiden.dk/tag/auto-login/" title="auto login" rel="tag">auto login</a>, <a href="http://xguiden.dk/tag/code/" title="code" rel="tag">code</a>, <a href="http://xguiden.dk/tag/content/" title="content" rel="tag">content</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/css3/" title="css3" rel="tag">css3</a>, <a href="http://xguiden.dk/tag/design/" title="design" rel="tag">design</a>, <a href="http://xguiden.dk/tag/element/" title="element" rel="tag">element</a>, <a href="http://xguiden.dk/tag/function/" title="function" rel="tag">function</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/input-type-text/" title="input type text" rel="tag">input type text</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/javascript-library/" title="javascript library" rel="tag">javascript library</a>, <a href="http://xguiden.dk/tag/jquery/" title="jquery" rel="tag">jquery</a>, <a href="http://xguiden.dk/tag/js/" title="js" rel="tag">js</a>, <a href="http://xguiden.dk/tag/login/" title="login" rel="tag">login</a>, <a href="http://xguiden.dk/tag/open-source-project/" title="open source project" rel="tag">open source project</a>, <a href="http://xguiden.dk/tag/scenarios/" title="scenarios" rel="tag">scenarios</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/transparent/" title="Transparent" rel="tag">Transparent</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a>, <a href="http://xguiden.dk/tag/webkit/" title="webkit" rel="tag">webkit</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/03/10/making-a-mosaic-slideshow-with-jquery-and-css/" title="Making a Mosaic Slideshow With jQuery and CSS (10/03/2010)">Making a Mosaic Slideshow With jQuery and CSS</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/sweet-ajax-tabs-with-jquery-1-4-and-css3/" title="Sweet AJAX Tabs With jQuery 1.4 and CSS3 (13/02/2010)">Sweet AJAX Tabs With jQuery 1.4 and CSS3</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/making-a-photoshoot-effect-with-jquery-css/" title="Making a Photoshoot Effect With jQuery and CSS (13/02/2010)">Making a Photoshoot Effect With jQuery and CSS</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/" title="How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout (03/03/2010)">How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/10/awesome-cssjs-form-styling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a Mosaic Slideshow With jQuery and CSS</title>
		<link>http://xguiden.dk/2010/03/10/making-a-mosaic-slideshow-with-jquery-and-css/</link>
		<comments>http://xguiden.dk/2010/03/10/making-a-mosaic-slideshow-with-jquery-and-css/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:11:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[css styles]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mosaic effect]]></category>
		<category><![CDATA[mosaic gallery]]></category>
		<category><![CDATA[mosaic slideshow]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[slide image]]></category>
		<category><![CDATA[slide style]]></category>
		<category><![CDATA[transition effect]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5559</guid>
		<description><![CDATA[When designing a product page, it is often necessary to present a number of images in a succession, also known as a slideshow. With the raise of the jQuery library and its numerous plugins, there is an abundance of ready-made solutions which address this problem. However, to make a lasting impression to your visitors, you [...]]]></description>
			<content:encoded><![CDATA[<p>When designing a product page, it is often necessary to present a number of images in a succession, also known as a slideshow. With the raise of the jQuery library and its numerous plugins, there is an abundance of ready-made solutions which address this problem. However, to make a lasting impression to your visitors, you need to present them with something they have not seen before.</p>
<p>Today we are making a jQuery &amp; CSS mosaic gallery. Mosaic, because it will feature an interesting tile transition effect when moving from one slide to another.</p>
<h3>Step 1 – XHTML</h3>
<p>The mosaic effect of the slideshow is achieved by dividing the original image into smaller parts. These tiles, which contain parts of the image, are sequentially hidden from view, which causes the effect. The markup of the slideshow is pretty straightforward. It consists of the main slideshow container element (<strong>#mosaic-slideshow</strong>), a left and right arrow for previous and next transition and the mosaic-slide div, which is inserted by jQuery at run-time.</p>
<h4>demo.html</h4>
<pre>&lt;div id="mosaic-slideshow"&gt;
	&lt;div class="arrow left"&gt;&lt;/div&gt;
	&lt;div class="arrow right"&gt;&lt;/div&gt;

	&lt;div class="mosaic-slide" style="z-index: 10;"&gt;

		&lt;!-- The mosaic-slide div and the tiles are generated by jQuery --&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;

	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The div with the <strong>mosaic-slide</strong> class name is added to the page by jQuery after the<strong> transition()</strong> JavaScript function is executed (we will come back to this in the third step). Inside it you can see the <strong>tile </strong>divs. There are a total of 56 such divs, each of which has a 60px by 60px portion of the slide image set as its background.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i1.jpg"><img class="size-full wp-image-766" src="http://tutorialzine.com/wp-content/uploads/2010/03/i1.jpg" alt="Mosaic Slideshow" width="620" height="460" /></a>Mosaic Slideshow</p>
</div>
<h3>Step 2 – CSS</h3>
<p>To make this effect work (and most importantly look good), we have to add a few lines of CSS. Only the code directly used by the gallery is shown here. You can see the code that styles the rest of the demonstration page in <strong>styles.css</strong>.</p>
<h4>styles.css – Part 1</h4>
<pre>#mosaic-slideshow{
	/* The slideshow container div */
	height:500px;
	margin:0 auto;
	position:relative;
	width:670px;
}

.mosaic-slide{
	/* This class is shared between all the slides */
	left:80px;
	position:absolute;
	top:25px;

	border:10px solid #555;

	/* CSS3 rounded corners */
	-moz-border-radius:20px;
	-webkit-border-radius:20px;
	border-radius:20px;
}

.tile{
	/* The individual tiles */
	height:60px;
	width:60px;
	float:left;
	border:1px solid #555;
	border-width:0 1px 1px 0;
	background-color:#555;
}</pre>
<p>The slideshow is contained inside the div with an ID of <strong>mosaic-slideshow</strong> (or #mosaic-slideshow, if we refer to it in a form of a CSS / jQuery selector).  There can be only one such div in the page, hence the use of an ID attribute.</p>
<p>However there can be more than one <strong>mosaic-slide</strong> divs in the page. The effect itself is achieved by stacking two slides on top of each other and hiding the tiles of the first one to reveal the ones of the second. This is why we are using a class name instead of an ID.</p>
<p>Some of the more interesting rules presented here are the three CSS3 rules for rounded corners. As the CSS3 standard is still a work in progress, browsers don’t support the regular <strong>border-radius </strong>property yet (except for the new 10.50 version of Opera), and need vendor-specific prefixes to recognize it. The<strong> -moz-</strong> prefix is used by Firefox, and <strong>-webkit-</strong> is used by Safari and Chrome.</p>
<h4>styles.css – Part 2</h4>
<pre>.arrow{
	/* The prev/next arrows */
	width:35px;
	height:70px;
	background:url("img/arrows.png") no-repeat;
	position:absolute;
	cursor:pointer;
	top:50%;
	margin-top:-35px;
}

.arrow.left{
	left:15px;
	background-position:center top;
}

.arrow.left:hover{
	background-position:center -70px;
}

.arrow.right{
	right:15px;
	background-position:center -140px;
}

.arrow.right:hover{
	background-position:center -210px;
}

.clear{
	/* This class clears the floats */
	clear:both;
}</pre>
<p>The <strong>arrow</strong> class is shared by the previous and next arrows. They do need individual styling in addition to this common rule, so we add it after this. We are also using a CSS sprite as the background for the arrow divs. It contains a regular and hover state for both arrows, which spares us from having to use four individual images.</p>
<blockquote><p>“<strong>CSS spriting</strong>” is a widespread technique used by web designers. It allows the designer to join multiple smaller images into a single larger one, called a sprite, which is downloaded faster and saves the web server from multiple download requests. After this, the designer can use the CSS background property in conjunction with setting the elements to a fixed size, to show only the part of the sprite image that they need.</p></blockquote>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i2.jpg"><img class="size-full wp-image-767" src="http://tutorialzine.com/wp-content/uploads/2010/03/i2.jpg" alt="Mosaic Slideshow" width="620" height="260" /></a>Mosaic Slideshow</p>
</div>
<h3>Step 3 – jQuery</h3>
<p>After including the jQuery library to the page, we can move on to creating the script that will make the slideshow tick. To achieve the mosaic effect, the script defines 4 functions:</p>
<ul>
<li><strong>transition()</strong> – this function makes an animated transition between the currently shown slide, and a new one specified by the id parameter. It works by positioning the new slide we want to show, below the current one, and then hiding the current one one tile at a time;</li>
<li><strong>generateGrid()</strong> – this function is used by transition() to generate a grid of tiles. Each tile contains a part of the slide image as its background;</li>
<li><strong>next()</strong> – detects which the next slide is and runs the transition() function with its index;</li>
<li><strong>prev()</strong> – analogous to next().</li>
</ul>
<h4>script.js – Part 1</h4>
<pre>/* The slide images are contained in the slides array. */
var slides = new Array('img/slide_1.jpg',
					   'img/slide_2.jpg',
					   'img/slide_3.jpg',
					   'img/slide_4.jpg',
					   'img/slide_5.jpg');

$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	$('.arrow.left').click(function(){
		prev();

		/* Clearing the autoadvance if we click one of the arrows */
		clearInterval(auto);
	});

	$('.arrow.right').click(function(){
		next();
		clearInterval(auto);
	});

	/* Preloading all the slide images: */

	for(var i=0;i&lt;slides.length;i++)
	{
		(new Image()).src=slides[i];
	}

	/* Showing the first one on page load: */
	transition(1);

	/* Setting auto-advance every 10 seconds */

	var auto;

	auto=setInterval(function(){
		next();
	},10*1000);
});</pre>
<p>The <strong>$(document).ready()</strong> method is executed once the page has finished loading. This will ensure that all the divs and other elements are accessible to the script. Inside it we bind a function for the click event on the previous and next arrows, preload all the images, show the first slide (otherwise the slideshow would be empty) and set up the auto-advance interval.</p>
<h4>script.js – Part 2</h4>
<pre>var current = {};
function transition(id)
{
	/* This function shows the slide specified by the id. */

	if(!slides[id-1]) return false;

	if(current.id)
	{
		/* If the slide we want to show is currently shown: */
		if(current.id == id) return false;

		/* Moving the current slide layer to the top: */
		current.layer.css('z-index',10);

		/* Removing all other slide layers that are positioned below */
		$('.mosaic-slide').not(current.layer).remove();
	}

	/* Creating a new slide and filling it with generateGrid: */
	var newLayer = $('&lt;div class="mosaic-slide"&gt;').html(generateGrid({rows:7,cols:8,image:slides[id-1]}));

	/* Moving it behind the current slide: */
	newLayer.css('z-index',1);

	$('#mosaic-slideshow').append(newLayer);

	if(current.layer)
	{
		/* Hiding each tile of the current slide, exposing the new slide: */
		$('.tile',current.layer).each(function(i){
			var tile = $(this);
			setTimeout(function(){
				tile.css('visibility','hidden');
			},i*10);
		})
	}

	/* Adding the current id and newLayer element to the current object: */
	current.id = id;
	current.layer = newLayer;
}</pre>
<p>The transition function uses the global <strong>current</strong> object to store the id of the currently shown slide, and a reference to the current slide div. This is later used to remove leftover slides and prevent a transition from occurring if the same slide as the currently active one is to be shown.</p>
<p>Notice how we use the each method on line 31 to loop through the tiles of the current slide and schedule them to be hidden in <strong>i*10 milliseconds</strong> in the future. As <strong>i</strong> is incremented for every tile, this mean that they are hidden 10 milliseconds apart from one another.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i31.png"><img class="size-full wp-image-768" src="http://tutorialzine.com/wp-content/uploads/2010/03/i31.png" alt="Slide Transition" width="620" height="460" /></a>Slide Transition</p>
</div>
<h4>script.js – Part 3</h4>
<pre>function next()
{
	if(current.id)
	{
		transition(current.id%slides.length+1);
	}
}

function prev()
{
	if(current.id)
	{
		transition((current.id+(slides.length-2))%slides.length+1);
	}

}

/* Width and height of the tiles in pixels: */
var tabwidth=60, tabheight=60;

function generateGrid(param)
{
	/* This function generates the tile grid, with each tile containing a part of the slide image */

	/* Creating an empty jQuery object: */
	var elem = $([]),tmp;

	for(var i=0;i&lt;param.rows;i++)
	{
		for(var j=0;j&lt;param.cols;j++)
		{
			tmp = $('&lt;div&gt;', {
					"class":"tile",
					"css":{
						"background":'#555 url('+param.image+') no-repeat '+(-j*tabwidth)+'px '+(-i*tabheight)+'px'
					}
			});

			/* Adding the tile to the jQuery object: */
			elem = elem.add(tmp);
		}

		/* Adding a clearing element at the end of each line. This will clearly divide the divs into rows: */
		elem = elem.add('&lt;div class="clear"&gt;&lt;/div&gt;');
	}

	return elem;
}</pre>
<p>The parameter passed to <strong>generateGrid()</strong> is an object containing the rows and the columns we want to be generated, as well as the image to be set as the background of the tiles. While generating the tiles, the background image is offset according to the current position of the tile in the row and in the column. Finally the tile is added to an empty jQuery object which is returned at the end.</p>
<p><strong>With this the mosaic slideshow is complete!</strong></p>
<h3>Wrapping it up</h3>
<p>Today we created a slideshow with an animated mosaic transition effect. You can modify it to include a different number of rows and columns or change the way slides are changed entirely.</p>
<p><strong>What do you think? How would you use this slideshow?</strong></p>
<p><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/0GM-mbwkGBs" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/code/" title="code" rel="tag">code</a>, <a href="http://xguiden.dk/tag/content/" title="content" rel="tag">content</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/css-styles/" title="css styles" rel="tag">css styles</a>, <a href="http://xguiden.dk/tag/css3/" title="css3" rel="tag">css3</a>, <a href="http://xguiden.dk/tag/design/" title="design" rel="tag">design</a>, <a href="http://xguiden.dk/tag/element/" title="element" rel="tag">element</a>, <a href="http://xguiden.dk/tag/function/" title="function" rel="tag">function</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/jquery/" title="jquery" rel="tag">jquery</a>, <a href="http://xguiden.dk/tag/mosaic-effect/" title="mosaic effect" rel="tag">mosaic effect</a>, <a href="http://xguiden.dk/tag/mosaic-gallery/" title="mosaic gallery" rel="tag">mosaic gallery</a>, <a href="http://xguiden.dk/tag/mosaic-slideshow/" title="mosaic slideshow" rel="tag">mosaic slideshow</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/slide-image/" title="slide image" rel="tag">slide image</a>, <a href="http://xguiden.dk/tag/slide-style/" title="slide style" rel="tag">slide style</a>, <a href="http://xguiden.dk/tag/transition-effect/" title="transition effect" rel="tag">transition effect</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/03/10/awesome-cssjs-form-styling/" title="Awesome CSS+JS form styling (10/03/2010)">Awesome CSS+JS form styling</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/sweet-ajax-tabs-with-jquery-1-4-and-css3/" title="Sweet AJAX Tabs With jQuery 1.4 and CSS3 (13/02/2010)">Sweet AJAX Tabs With jQuery 1.4 and CSS3</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/making-a-photoshoot-effect-with-jquery-css/" title="Making a Photoshoot Effect With jQuery and CSS (13/02/2010)">Making a Photoshoot Effect With jQuery and CSS</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/" title="How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout (03/03/2010)">How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/10/making-a-mosaic-slideshow-with-jquery-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design and Code a Cool iPhone App Website in HTML5</title>
		<link>http://xguiden.dk/2010/03/08/design-and-code-a-cool-iphone-app-website-in-html5/</link>
		<comments>http://xguiden.dk/2010/03/08/design-and-code-a-cool-iphone-app-website-in-html5/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 11:41:59 +0000</pubDate>
		<dc:creator>DiscoTK</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[DOCTYPE]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[FireFox]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Glow]]></category>
		<category><![CDATA[Header]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[LP]]></category>
		<category><![CDATA[Mod]]></category>
		<category><![CDATA[Mount]]></category>
		<category><![CDATA[Outline]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[porte]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Start]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[textur]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5520</guid>
		<description><![CDATA[HTML5 is definitely the flavor of the month, with everyone in the design community getting excited about its release. In this tutorial we’ll get a taste of what’s to come by building a cool iPhone app website using a HTML5 structure, and visual styling with some CSS3 effects.

HTML5 isn’t here just yet, but the Working [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 is definitely the flavor of the month, with everyone in the design community getting excited about its release. In this tutorial we’ll get a taste of what’s to come by building a cool iPhone app website using a HTML5 structure, and visual styling with some CSS3 effects.</p>
<p><a href="http://line25.com/wp-content/uploads/2010/html5/demo/index.html"><img src="http://line25.com/wp-content/uploads/2010/html5/12.png" alt="iPhone app website for PKE Meter" /></a></p>
<p>HTML5 isn’t here just yet, but the Working Draft is complete enough for us to play around and get to grips with the exciting new elements we can use in our code. To learn how a few of these elements can be used, let’s put together a simple website for say, a fictional iPhone app.  This tutorial covered the process of building an interface just like the awesome apps from <a href="http://tapbots.com/">Tapbots</a>, so head over and check it out, then we’ll be ready to build an accompanying website for our PKE Meter application.</p>
<p><a href="http://line25.com/wp-content/uploads/2010/html5/demo/index.html">View the demo</a></p>
<h3>The PSD concept</h3>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/01.png" alt="" /></p>
<p>First, we’ll need to put together a concept for our app website. Create a new document in Photoshop. I use the dimensions of 1680×1050 to give a typical widescreen monitor resolution to work with.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/02.png" alt="" /></p>
<p>Fill the background with grey (#252525), then add some subtle texture by heading to Filter &gt; Noise &gt; Add Noise. Select the Gaussian and Monochromatic options and set the amount to 1.3%.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/03.png" alt="" /></p>
<p>Draw a simple app icon with the rounded rectangle, and type out the name of our app in Helvetica Bold.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/04.png" alt="" /></p>
<p>Double click the layer of each object to add some layer styling. Give each one a Color Overlay of #00ffcc and a soft Outer Glow to create an illuminated appearance.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/05.png" alt="" /></p>
<p>CMD-Click the layer thumbnail of each object to load the selection, then fill a new layer with a horizontal scan-lines pattern.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/06.png" alt="" /></p>
<p>Change the blending mode of the scan-lines to Multiply and drop the opacity to around 35%. Add a little logo and the usual highlight to the iPhone icon graphic.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/07.png" alt="" /></p>
<p>Type out an enticing introduction for the app with the type tool and add the same illuminated layer style. If you haven’t guessed already, the PKE Meter is the tool Egon Spengler uses in Ghostbusters. If Egon was busting ghosts in 2010, there’s no doubt he’d be using his iPhone to track psycho-kinetic energy.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/08.png" alt="" /></p>
<p>Fill out the design with a description of the app. To give the text a little extra pop, add a black drop shadow.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/09.png" alt="" /></p>
<p>Take the time to line-up the elements of your design and finish off the description of the app with a list of features.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/10.png" alt="" /></p>
<p>Download the handy <a href="http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/">iPhone UI kit</a> from <a href="http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/">Teehan+Lax</a> and paste in the custom app screenshot in place. Position the iPhone over to the right. Keeping the scale pretty large will help it act as a main focal point for the design and maintain the small details of the app interface.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/11.png" alt="" /></p>
<p>No iPhone app website would be complete without the ‘Available on the App Store’ badge. Paste in a copy of the badge and add some general styling with a subtle Inner Shadow.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/12.png" alt="" /></p>
<p>With just some copyright and disclaimer information added to the footer area, the concept is ready to be sliced and exported. Save the logo, the large iPhone graphic, the app store badge and a clipping of the textured background as PNG graphics.</p>
<h3>The HTML5 structure</h3>
<div>
<pre>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;PKE METER app for iPhone&lt;/title&gt;
	&lt;link href="style.css" rel="stylesheet" type="text/css" media="screen" /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div id="container"&gt;

	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
<p>Next we’ll put together the basics for the HTML index page. The HTML5 doctype is pretty simple indeed. Just add <code>&lt;!DOCTYPE html&gt;</code>. This is followed by some familiar HTML that outlines the <code>&lt;head&gt;</code> and <code>&lt;body&gt;</code>. We’ll add a div with an id of container to enclose all the content in a fixed width.</p>
<div>
<pre>&lt;header&gt;
	&lt;img src="images/logo.png" alt="PKE Meter" id="logo" /&gt;
	&lt;h1&gt;Track ghosts,&lt;br&gt; on your iPhone&lt;/h1&gt;
&lt;/header&gt;
</pre>
</div>
<p>Now the new HTML5 elements will come into play. The <code>&lt;header&gt;</code> element is used to enclose a group of introductory or navigational aids. The logo and intro title of our design would fit perfectly here. The logo itself is added as an image, and the intro, being the most descriptive element is coded in a <code>&lt;h1&gt;</code>.</p>
<div>
<pre>&lt;section&gt;
	&lt;p&gt;Follow in the footsteps of Ghostbuster legend Egon Spengler and become a doctor of parapsychology with the PKE METER app for iPhone.&lt;/p&gt;

	&lt;h2&gt;Features:&lt;/h2&gt;
	&lt;ul&gt;
		&lt;li&gt;Study paranormal activity.&lt;/li&gt;
		&lt;li&gt;Track sources of psycho-kinetic energy.&lt;/li&gt;
		&lt;li&gt;Measure supernatural energy readings.&lt;/li&gt;
	&lt;/ul&gt;
&lt;/section&gt;
</pre>
</div>
<p>A <code>&lt;section&gt;</code> in HTML5 refers to a grouping of content, so all the information about the app in our design can be enclosed in the section element.</p>
<div>
<pre>&lt;aside&gt;
	&lt;a href="#"&gt;&lt;img src="images/iphone.png" alt="iPhone showcasing a screenshot of the PKE METER app." /&gt;&lt;/a&gt;
&lt;/aside&gt;
</pre>
</div>
<p>An <code>&lt;aside&gt;</code> in HTML5 is pretty similar to a <code>&lt;section&gt;</code> as it also basically a grouping of content, but an aside is used specifically for separate content that has a connection to a nearby section. The large graphic of the iPhone and app screenshot is related to the information that’s within the adjacent <code>&lt;section&gt;</code> element in our design, so it would work well as an aside.</p>
<div>
<pre>&lt;footer&gt;
	&lt;a href="#" id="app-store"&gt;Available on the iPhone app store&lt;/a&gt;

	&lt;p&gt;&lt;small&gt;&amp;copy; Paranormal Lab of Columbia University.&lt;/small&gt;&lt;/p&gt;
	&lt;p&gt;&lt;small&gt;Use of PKE METER for long periods may result in brain cell mutation.&lt;/small&gt;&lt;/p&gt;
&lt;/footer&gt;
</pre>
</div>
<p>The <code>&lt;footer&gt;</code> element is another handy structural HTML tag that replaces the old <code>&lt;div id="footer"&gt;</code> method with something more descriptive. Within the footer I’ve used <code>&lt;small&gt;</code> tags to surround the copyright and disclaimer. The <code>&lt;small&gt;</code> element is used to represent small print, and can be used for disclaimers, caveats, legal restrictions and copyrights (not small as in size, as the name suggests.)</p>
<div>
<pre>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;PKE METER app for iPhone&lt;/title&gt;
	&lt;link href="style.css" rel="stylesheet" type="text/css" media="screen" /&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div id="container"&gt;
		&lt;header&gt;
			&lt;img src="images/logo.png" alt="PKE Meter" id="logo" /&gt;
			&lt;h1&gt;Track ghosts,&lt;br&gt; on your iPhone&lt;/h1&gt;
		&lt;/header&gt;

		&lt;section&gt;
			&lt;p&gt;Follow in the footsteps of Ghostbuster legend Egon Spengler and become a doctor of parapsychology with the PKE METER app for iPhone.&lt;/p&gt;

			&lt;h2&gt;Features:&lt;/h2&gt;
			&lt;ul&gt;
				&lt;li&gt;Study paranormal activity.&lt;/li&gt;
				&lt;li&gt;Track sources of psycho-kinetic energy.&lt;/li&gt;
				&lt;li&gt;Measure supernatural energy readings.&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/section&gt;

		&lt;aside&gt;
			&lt;a href="#"&gt;&lt;img src="images/iphone.png" alt="iPhone showcasing a screenshot of the PKE METER app." /&gt;&lt;/a&gt;
		&lt;/aside&gt;

		&lt;footer&gt;
			&lt;a href="#" id="app-store"&gt;Available on the iPhone app store&lt;/a&gt;

			&lt;p&gt;&lt;small&gt;&amp;copy; Paranormal Lab of Columbia University.&lt;/small&gt;&lt;/p&gt;
			&lt;p&gt;&lt;small&gt;Use of PKE METER for long periods may result in brain cell mutation.&lt;/small&gt;&lt;/p&gt;
		&lt;/footer&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
<p>So here’s our simple HTML5 page altogether. We’ve only used a couple of the new elements, but that’s all we needed for this particular design. It has however, enabled us to create a really clean markup and has seriously cut down on the number of <code>&lt;div&gt;</code> tags scattered around the HTML, making it much more easy to see where specific sections start and end.</p>
<h3>The CSS styling</h3>
<div>
<pre>body, div, h1, h2, h3, h4, h5, h6, p, ul, li, img, header, section, aside, footer, button {
	margin: 0; padding: 0; border: 0;
}

body {
	font-family: Helvetica, Arial, Sans-Serif;
	background: #2b2b2b url(images/bg.png);
}

#container {
	width: 960px;
	margin: 0 auto;
	padding: 90px 0 100px 0;
	position: relative;
	overflow: hidden;
}
</pre>
</div>
<p>Now it’s time to get everything styled up according to the visual concept. To begin, the stylesheet is given a quick reset to strip out the browser default styling, the body is given the dark textured background and the containing div is positioned centrally.</p>
<div>
<pre>header {}
	header img#logo {
		margin: 0 0 50px 0;
	}
	header h1 {
		margin: 0 0 30px 90px;
		font-size: 60px;
		font-weight: normal;
		line-height: 74px;
		color: #00ffcc;
		text-shadow: 0px 0px 10px #00ffcc;
	}
</pre>
</div>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/13.png" alt="" /></p>
<p>The logo and title can be moved into position by editing their margins, and the text for the intro title can be styled up the match the visual concept by adding the bright green color, and the illuminated effect with the CSS3 <code>text-shadow</code> property.</p>
<div>
<pre>section {
	margin: 0 15px 30px 0;
	width: 530px;
	float: left;
}
	section p {
		margin: 0 0 30px 90px;
		font-size: 22px;
		line-height: 35px;
		color: #d9d9d9;
		text-shadow: 0px 1px 5px #000;
	}
	section h2 {
		margin: 0 0 10px 90px;
		font-size: 40px;
		font-weight: normal;
		color: #00ffcc;
		text-shadow: 0px 0px 10px #00ffcc;
	}
	section ul {
		margin: 0 0 30px 90px;
		font-size: 22px;
		line-height: 45px;
		color: #d9d9d9;
		text-shadow: 0px 1px 5px #000;
	}
</pre>
</div>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/14.png" alt="" /></p>
<p>The <code>&lt;section&gt;</code> that contains all the textual information is given a specific width and floated to the left, and all the subsequent content elements such as the header two, paragraphs and unordered list are all given the appropriate font-sizing, margin and coloring to match the PSD concept.</p>
<div>
<pre>aside {
	position: absolute;
	top: 20px;
	right: 0;
}
</pre>
</div>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/15.png" alt="" /></p>
<p>The <code>&lt;aside&gt;</code> can then be moved into place with some absolute positioning. This ensures the iPhone graphic appears 20px from the top of the page, relative to the containing div.</p>
<div>
<pre>footer {
	width: 960px;
	float: left;
	clear: both;
	overflow: hidden;
}
	footer a#app-store {
		display: block;
		width: 198px;
		height: 72px;
		background: url(images/app-store.png);
		text-indent: -9999px;
		margin: 0 0 0 84px;
		float: left;
	}
	footer p {
		float: right;
		clear: right;
		font-size: 16px;
		color: #5a5a5a;
		margin: 10px 0 0 0;
	}
</pre>
</div>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/16.png" alt="" /></p>
<p>The footer can then be cleared so that it sits underneath the previous content and given an <code>overflow:hidden</code> declaration to clear itself after the floats used on the anchor and paragraphs. Speaking of anchors and paragraphs, these elements are each given moved into place with floats to finish off the CSS.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/17.png" alt="" /></p>
<p>Previewing the site in Firefox, Chrome and Safari will show the site in all its coded glory. Unfortunately, Internet Explorer doesn’t share support for HTML5, so it needs a little extra work.</p>
<div>
<pre>&lt;script&gt;
  document.createElement('header');
  document.createElement('footer');
  document.createElement('section');
  document.createElement('aside');
&lt;/script&gt;
</pre>
</div>
<p><img src="http://line25.com/wp-content/uploads/2010/html5/18.png" alt="" /></p>
<p>Because IE doesn’t support HTML5, it just doesn’t recognise those new fancy elements. The good news is it’s easy to tell IE to create them anyway by adding the above Javascript to your <code>&lt;head&gt;</code>. As soon as this code is added, everything looks perfect in IE, albeit with the cool illumination effects being gracefully degraded. It’s worth noting that if Javascript is turned off, IE will show the broken version of the site. Chances are with an iPhone app website like this, the majority of the visitors are going to be clued up on their browsers, so it’s a risk that we could take for this particular design.</p>
<p><a href="http://line25.com/wp-content/uploads/2010/html5/demo/index.html">View the demo</a></p>

	Tags: <a href="http://xguiden.dk/tag/avi/" title="avi" rel="tag">avi</a>, <a href="http://xguiden.dk/tag/chrome/" title="Chrome" rel="tag">Chrome</a>, <a href="http://xguiden.dk/tag/community/" title="Community" rel="tag">Community</a>, <a href="http://xguiden.dk/tag/cool/" title="Cool" rel="tag">Cool</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/css3/" title="css3" rel="tag">css3</a>, <a href="http://xguiden.dk/tag/design/" title="design" rel="tag">design</a>, <a href="http://xguiden.dk/tag/doctype/" title="DOCTYPE" rel="tag">DOCTYPE</a>, <a href="http://xguiden.dk/tag/fil/" title="fil" rel="tag">fil</a>, <a href="http://xguiden.dk/tag/firefox/" title="FireFox" rel="tag">FireFox</a>, <a href="http://xguiden.dk/tag/fix/" title="fix" rel="tag">fix</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/glow/" title="Glow" rel="tag">Glow</a>, <a href="http://xguiden.dk/tag/header/" title="Header" rel="tag">Header</a>, <a href="http://xguiden.dk/tag/help/" title="help" rel="tag">help</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/html5/" title="html5" rel="tag">html5</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/images/" title="images" rel="tag">images</a>, <a href="http://xguiden.dk/tag/internet/" title="internet" rel="tag">internet</a>, <a href="http://xguiden.dk/tag/internet-explorer/" title="Internet Explorer" rel="tag">Internet Explorer</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/lp/" title="LP" rel="tag">LP</a>, <a href="http://xguiden.dk/tag/mod/" title="Mod" rel="tag">Mod</a>, <a href="http://xguiden.dk/tag/mount/" title="Mount" rel="tag">Mount</a>, <a href="http://xguiden.dk/tag/outline/" title="Outline" rel="tag">Outline</a>, <a href="http://xguiden.dk/tag/over/" title="Over" rel="tag">Over</a>, <a href="http://xguiden.dk/tag/photoshop/" title="Photoshop" rel="tag">Photoshop</a>, <a href="http://xguiden.dk/tag/png/" title="png" rel="tag">png</a>, <a href="http://xguiden.dk/tag/porte/" title="porte" rel="tag">porte</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/source/" title="Source" rel="tag">Source</a>, <a href="http://xguiden.dk/tag/start/" title="Start" rel="tag">Start</a>, <a href="http://xguiden.dk/tag/tag/" title="tag" rel="tag">tag</a>, <a href="http://xguiden.dk/tag/tags/" title="tags" rel="tag">tags</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a>, <a href="http://xguiden.dk/tag/textur/" title="textur" rel="tag">textur</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a>, <a href="http://xguiden.dk/tag/url/" title="URL" rel="tag">URL</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/" title="How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout (03/03/2010)">How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/18/coding-a-css3-html5-one-page-website-template/" title="Coding a CSS3 &amp; HTML5 One-Page Website Template (18/02/2010)">Coding a CSS3 &amp; HTML5 One-Page Website Template</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/03/03/design-a-prettier-web-form-with-css-3/" title="Design a Prettier Web Form with CSS 3 (03/03/2010)">Design a Prettier Web Form with CSS 3</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/how-to-make-a-css-sprite-powered-menu/" title="How to Make a CSS Sprite Powered Menu (13/02/2010)">How to Make a CSS Sprite Powered Menu</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/08/design-and-code-a-cool-iphone-app-website-in-html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creative Button Animations with Sprites and JQuery (Part 2: CSS, XHTML, JQuery)</title>
		<link>http://xguiden.dk/2010/03/03/creative-button-animations-with-sprites-and-jquery-part-2-css-xhtml-jquery/</link>
		<comments>http://xguiden.dk/2010/03/03/creative-button-animations-with-sprites-and-jquery-part-2-css-xhtml-jquery/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 22:06:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5323</guid>
		<description><![CDATA[In Part 1 of this tutorial, you designed a button sprite that will be coded with HTML, CSS, and JQuery in this part of the tutorial.
If you do not want to complete part one of this tutorial, you can download the source files created in that lesson here.
Step 1 – HTML
Different people will require a [...]]]></description>
			<content:encoded><![CDATA[<p>In Part 1 of this tutorial, you designed a button sprite that will be coded with HTML, CSS, and JQuery in this part of the tutorial.</p>
<p>If you do not want to complete part one of this tutorial, you can <strong>download the source files</strong> created in that lesson <a href="http://tutorial9.s3.amazonaws.com/wp-content/uploads/2010/02/Button-Source-Files-and-Demo.zip">here</a>.</p>
<h3>Step 1 – HTML</h3>
<p>Different people will require a button for different purposes. The remainder of this tutorial will explain a simple scenario where the button functions as a simple download link. Create a link to an imaginary (<em>or real</em>) file for download:</p>
<pre>&lt;a href="path/to/download.zip" class="button"&gt;&lt;/a&gt;</pre>
<h3>Step 2 – CSS</h3>
<p>Add the following CSS to your HTML document:</p>
<pre>.button {
	width:570px;
	height:64px; /* Notice that the height is not the height of the whole sprite, but the height of one single button */
	display:block;
	background-image:url(images/downloadbutton.png); /*path to the sprite*/
	background-position: top; /* the background position (in combination with the height!) makes it possible that only the top of the whole sprite will be visible */
}</pre>
<p>When you apply the CSS code above, you will only see the <strong>grey</strong> button, because it’s <em>positioned on top</em> and the <em>height is 64px</em></p>
<p><strong>Link hover button</strong></p>
<pre>.button:hover{
	width:570px;
	background-position: bottom;
	height:64px;
	background-image:url(images/downloadbutton.png) no repeat;
}</pre>
<p>When you apply the CSS code above, you will only see the <strong>green</strong> button when you hover the download button, because it’s <em>positioned at the bottom</em> and the <em>height is 64px</em></p>
<p><strong>Demo:</strong> <a rel="external" href="http://tutorial9.net/demos/button-sprites/demo.html">View Live Demo</a></p>
<h3>Step 3 – Fading hover effect</h3>
<p>This step is not necessary, but it’s an optional step. The transition will be smoothed with JavaScript. We’re going to use the popular jQuery library.</p>
<p>The original tutorial comes from <a rel="external" href="http://greg-j.com/static-content/hover-fade-redux.html">this website</a>. I’ll do my best to explain.</p>
<h3>Step 4 – Add code between the head tags</h3>
<p><a rel="external" href="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js">Download jQuery</a>. First we need to refer in the head to the .js file that we’ve just downloaded.</p>
<pre>&lt;script type="text/javascript" src="path/to/jquery-1.3.2.min.js"&gt;&lt;/script&gt;</pre>
<p>After that we can add the following code between the head tags.</p>
<pre>&lt;script type="text/javascript"&amp;gt
	$(document).ready(function() {
		// Add the class 'button' just like in CSS with a dot in front of it
		$('.button').append('&lt;span class="hover"&amp;gt&lt;/span&amp;gt').each(function () {
	  		var $span = $('&amp;gt span.hover', this).css('opacity', 0);
	  		$(this).hover(function () {
	    		$span.stop().fadeTo(500, 1); //Change the number 500 to change the speed of the Fade In
	 		}, function () {
	   	$span.stop().fadeTo(500, 0); //Change the number 500 to change the speed of the Fade Out
	  		});
		});
	});
&lt;/script&gt;</pre>
<div>
<h4>How to deal with several buttons on one page</h4>
<p>If you have several buttons on one page and you’d like to add the fading hover effect, you can give it a different class in the HTML and add this in the JavaScript above after the word .button and you need also to separate the words with a comma. (Example: ‘.button,.buttonTwo’)</p>
</div>
<h3>Step 5 – Edit the CSS</h3>
<pre>.button {
	position:relative;
	display:block;
	height: 64px;
	width: 570px;
	background:url(images/downloadbutton.png) no-repeat;
	background-position: top;
}</pre>
<pre>.button span.hover { /*notice the different class: span.hover*/
	position: absolute;
	display: block;
	height: 64px;
	width: 570px;
	background: url(images/downloadbutton.png) no-repeat;
	background-position: bottom;
}</pre>
<p><a rel="external" href="http://tutorial9.net/demos/button-sprites/demo.html">View Live Demo</a> to check the result.</p>
<h3>Download the source files (PSD included)</h3>
<div><a rel="external" href="http://www.tutorial9.net/wp-content/uploads/2010/02/Button-Source-Files-and-Demo.zip">Download</a></div>
<p><a href="http://feedads.g.doubleclick.net/~a/wmKScpUgbZJn0S3ZMx4Pr4Cgi7I/0/da"><img src="http://feedads.g.doubleclick.net/~a/wmKScpUgbZJn0S3ZMx4Pr4Cgi7I/0/di" border="0" alt="" /></a><br />
<a href="http://feedads.g.doubleclick.net/~a/wmKScpUgbZJn0S3ZMx4Pr4Cgi7I/1/da"><img src="http://feedads.g.doubleclick.net/~a/wmKScpUgbZJn0S3ZMx4Pr4Cgi7I/1/di" border="0" alt="" /></a></p>
<div><a href="http://feeds.feedburner.com/~ff/tutorial9?a=ah9hL4UWD4Q:F8fjrMYYvMY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/tutorial9?i=ah9hL4UWD4Q:F8fjrMYYvMY:D7DqB2pKExk" border="0" alt="" /></a> <a href="http://feeds.feedburner.com/~ff/tutorial9?a=ah9hL4UWD4Q:F8fjrMYYvMY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/tutorial9?i=ah9hL4UWD4Q:F8fjrMYYvMY:gIN9vFwOqvQ" border="0" alt="" /></a> <a href="http://feeds.feedburner.com/~ff/tutorial9?a=ah9hL4UWD4Q:F8fjrMYYvMY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/tutorial9?i=ah9hL4UWD4Q:F8fjrMYYvMY:F7zBnMyn0Lo" border="0" alt="" /></a> <a href="http://feeds.feedburner.com/~ff/tutorial9?a=ah9hL4UWD4Q:F8fjrMYYvMY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/tutorial9?d=7Q72WNTAKBA" border="0" alt="" /></a> <a href="http://feeds.feedburner.com/~ff/tutorial9?a=ah9hL4UWD4Q:F8fjrMYYvMY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/tutorial9?d=qj6IDK7rITs" border="0" alt="" /></a></div>
<p><img src="http://feeds.feedburner.com/~r/tutorial9/~4/ah9hL4UWD4Q" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/animation/" title="animation" rel="tag">animation</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/design/" title="design" rel="tag">design</a>, <a href="http://xguiden.dk/tag/fil/" title="fil" rel="tag">fil</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/images/" title="images" rel="tag">images</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/over/" title="Over" rel="tag">Over</a>, <a href="http://xguiden.dk/tag/png/" title="png" rel="tag">png</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/source/" title="Source" rel="tag">Source</a>, <a href="http://xguiden.dk/tag/tag/" title="tag" rel="tag">tag</a>, <a href="http://xguiden.dk/tag/tags/" title="tags" rel="tag">tags</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a>, <a href="http://xguiden.dk/tag/url/" title="URL" rel="tag">URL</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/03/08/design-and-code-a-cool-iphone-app-website-in-html5/" title="Design and Code a Cool iPhone App Website in HTML5 (08/03/2010)">Design and Code a Cool iPhone App Website in HTML5</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/jquery-ajax-validation-contact-form-with-modal-slide-in-transition/" title="jQuery AJAX Validation Contact Form with Modal + Slide-in Transition (13/02/2010)">jQuery AJAX Validation Contact Form with Modal + Slide-in Transition</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/" title="How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout (03/03/2010)">How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/18/coding-a-css3-html5-one-page-website-template/" title="Coding a CSS3 &amp; HTML5 One-Page Website Template (18/02/2010)">Coding a CSS3 &amp; HTML5 One-Page Website Template</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/03/creative-button-animations-with-sprites-and-jquery-part-2-css-xhtml-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Learning jQuery 1.4’s $.proxy</title>
		<link>http://xguiden.dk/2010/03/03/quick-tip-learning-jquery-1-4%e2%80%99s-proxy/</link>
		<comments>http://xguiden.dk/2010/03/03/quick-tip-learning-jquery-1-4%e2%80%99s-proxy/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 21:54:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5357</guid>
		<description><![CDATA[One of my favorite new features in jQuery 1.4 is the new $.proxy method. It allows us force a particular context when calling a method. In JavaScript, there can be times when it’s difficult to hold on to the this keyword. For example, when it’s bound to some event handler, this now refers to the [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite new features in jQuery 1.4 is the new $.proxy method. It allows us force a particular context when calling a method. In JavaScript, there can be times when it’s difficult to hold on to the <em>this</em> keyword. For example, when it’s bound to some event handler, <em>this</em> now refers to the target of the handler, rather than your desired object.</p>
<p>If this sounds a bit confusing, don’t worry; today’s four-minute video quick tip should clear things up.</p>
<p><span> </span></p>
<div><a href="http://jsbin.com/inupo"><img src="http://net.tutsplus.com/wp-content/themes/nettuts/site_images/button_src_nm.jpg" alt="" /></a><br />
<a href="http://jsbin.com/inupo"><img src="http://net.tutsplus.com/wp-content/themes/nettuts/site_images/button_demo_nm.jpg" alt="" /></a></div>
<pre>// Create an object.
var obj = {
        // this = obj
	somevar : 'some value',

	doSomething : function() {
		alert(this.somevar);
	}
};

// When bound to an event handler, this will
// refer to the target of the handler, or the div - not obj.
$('div').click(obj.doSomething); // undefined. 

// With $.proxy, we pass two parameters.
// 1. The method to call.
// 2. The context.
// In this case, we're forcing obj to once again be equal to this.
$('div').click( $.proxy(obj.doSomething, obj) ); // some value</pre>
<p><img src="http://feeds.feedburner.com/~r/nettuts/~4/kgBwvQ-R2iY" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/images/" title="images" rel="tag">images</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/02/13/use-ajax-to-create-a-cacheing-system/" title="Use ajax to create a cacheing system (13/02/2010)">Use ajax to create a cacheing system</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/smooth-horizontal-tweened-menu-with-as3/" title="Smooth Horizontal Tweened Menu with AS3 (13/02/2010)">Smooth Horizontal Tweened Menu with AS3</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/quick-and-easy-way-to-implement-drag-n-share-with-jquery/" title="Quick and Easy Way to Implement Drag n Share With jQuery (13/02/2010)">Quick and Easy Way to Implement Drag n Share With jQuery</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/making-image-overlay-caption-using-css/" title="Making Image Overlay Caption Using CSS (13/02/2010)">Making Image Overlay Caption Using CSS</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/jquery-fade-in-fade-out-effect-%e2%80%93-updated/" title="Jquery Fade In, Fade Out Effect – Updated (13/02/2010)">Jquery Fade In, Fade Out Effect – Updated</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/03/quick-tip-learning-jquery-1-4%e2%80%99s-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout</title>
		<link>http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/</link>
		<comments>http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 21:54:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[counter]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[DOCTYPE]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[FireFox]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Header]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[META]]></category>
		<category><![CDATA[Mod]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[porte]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[switch]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[Transparent]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[Wanted]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5360</guid>
		<description><![CDATA[
Graceful Degradation
Since HTML5 and CSS3 aren’t going to be supported in all the browsers, especially not older ones like IE6, we can try and make it work in everything, but it won’t look the same in all of the browsers. For instance, rounded corners wont work in IE or Opera, but it wont affect the [...]]]></description>
			<content:encoded><![CDATA[<div><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebtint.net%2Ftutorials%2Fhow-well-be-building-websites-in-5-years-html5-and-css3-layout%2F"></a></div>
<h1>Graceful Degradation</h1>
<p>Since HTML5 and CSS3 aren’t going to be supported in all the browsers, especially not older ones like IE6, we can try and make it work in everything, but it won’t look the same in all of the browsers. For instance, rounded corners wont work in IE or Opera, but it wont affect the usability of that web page. Likewise, the flexible box model only works in Firefox and Webkit.</p>
<p>What we can do is we can set up a failsafe so that the web page will work in every browser correctly, but not in the same way. For instance, I made it so that in Webkit browsers, the page uses the flexible box model. However everywhere else it just switches to the old fashioned way and floats the elements to either side to create columns.</p>
<p>Overall this is the best way to handle issues like this. Instead of compromising a users experience, just make it work but in a different way. The experience doesn’t have to be linear across all browsers.</p>
<h1>A HTML5 Document</h1>
<p>The basic HTML5 layout, or the skeleton of it if you will, is nothing that new. Your mind will not be blown.</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;meta charset="utf-8" /&gt;

&lt;title&gt;HTML5 and CSS3 Layout&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p>One of the most notable differences is the addition of the new doctype, <code>&lt;!DOCTYPE html&gt;</code>, which is way easier to use than the old ones HTML has provided us with. Then we just do all the normal stuff, such as define the charset, title and link.</p>
<h2>New and Fancy</h2>
<p>Traditionally web pages are designed like this.<br />
<img src="http://webtint.net/wp-content/uploads/2010/02/old-website.gif" alt="Traditional Layout" width="580" height="580" /></p>
<p>With HTML5 we replace all those divs with specific elements, such as <code>&lt;header&gt;</code> and <code>&lt;aside&gt;</code>. This is a big step up from having to define our own elements with id’s and stuff, and makes HTML a lot more specific. When HTML4 was released, it wasn’t released with the web of 2010 in mind. HTML5 on the other hand was.</p>
<p>Don’t think the div is an unnecessary piece of baggage on the HTML5 specification, as it still has as many uses now as it did when HTML4 was released. Most HTML5 tags work in Webkit (well, in Chrome 5 anyway), so that’s the browser I’ve been using to make all of this flow together. However, Firefox doesn’t center the flexible box model correctly, and IE is, well, IE, so I’ve had to throw in a bunch of hacks to make this work correctly.</p>
<p>First off, stick this script in the head of your document.</p>
<pre>&lt;!--[if IE]&gt;
&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="iehacks.css" /&gt;
&lt;![endif]--&gt;

&lt;!--[if lte IE 7]&gt;
&lt;link rel="stylesheet" type="text/css" href="ie67hacks.css" /&gt;
&lt;![endif]--&gt;</pre>
<p>HTML5 tags wont work in IE, so the little javascript bit fixes that. The CSS files are there so we can fix some errors later on with the design. Oh, and by the way, this is the pretty basic design we’re going to be doing today. I’ve tried to keep it simple so that you can get a good idea of what HTML5 and CSS3 can do, rather than over complicating the process.<br />
<a href="http://webtint.net/filebank/html5css3"><img src="http://webtint.net/wp-content/uploads/2010/02/design.gif" alt="Design" width="580" height="699" /><br />
</a></p>
<h1>The Body</h1>
<p>The body is probably the bit that you’re most worried about. HTML5 tags are a tad different from their HTML4 counterparts, but really only by their names with most of the new tags acting like &lt;div&gt; and &lt;span&gt; tags.</p>
<h2>Header</h2>
<p>Lets work on the header. We’re going to be using the <code>&lt;header&gt;</code> tag for this one. It’s new to HTML5, and is defined as the following:</p>
<blockquote><p>The header element represents a group of introductory or navigational aids.</p></blockquote>
<p>So basically the header tag contains some navigational elements and the logo or introductory text. For the navigation we’ll be using the <code>&lt;nav&gt;</code> tag, and we’ll just be using a <code>&lt;div&gt;</code> for the logo. So the skeleton of the <code>&lt;header&gt;</code> element is going to look a bit like this:</p>
<pre>&lt;header&gt;
	&lt;div id="logo"&gt;
		...
	&lt;/div&gt;
	&lt;nav&gt;
		...
	&lt;/nav&gt;
&lt;/header&gt;</pre>
<p>Then it’s just a case of adding the content to these elements. For the <code>#logo div</code>, we can stick a logo image in, or we could use headings. If you’re going to use headings, and have multiple headings (i.e. <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code>), we can use the <code>&lt;hgroup&gt;</code> tag. The definition for the <code>&lt;hgroup&gt;</code> tag is..</p>
<blockquote><p>The hgroup element represents the heading of a section. The element is used to group a set of h1–h6 elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.</p></blockquote>
<p>So for example, you could have this in the logo area:</p>
<pre>&lt;hgroup&gt;
	&lt;h1&gt;Webtint&lt;/h1&gt;
	&lt;h2&gt;Web Development Blog&lt;/h2&gt;
&lt;/hgroup&gt;</pre>
<p>‘course, I’m just going to use an image instead, but heck, <a href="http://webtint.net/logo.gif">if you want to use the logo I stuck together feel free by getting it from here</a>.</p>
<pre>		&lt;a href="#"&gt;&lt;img src="images/logo.gif" alt="Logo" /&gt;&lt;/a&gt;</pre>
<p>Inside the <code>&lt;nav&gt;</code> we’ll just use an unordered list.</p>
<pre>		&lt;ul&gt;
			&lt;li&gt;&lt;a href="#"&gt;home&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;tutorials&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;resources&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;articles&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;forums&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;contact&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;</pre>
<h2>The Content</h2>
<p>For the content area, I’ve went for a structure like this:</p>
<pre>&lt;div id="content"&gt;
	&lt;section class="hfeed"&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt; ...&lt;/h2&gt;
				&lt;h3&gt; ... &lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt; ... &lt;/p&gt;
			&lt;footer&gt; ... &lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
	&lt;/section&gt;
	&lt;aside&gt;
		...
	&lt;/aside&gt;
&lt;/div&gt;</pre>
<p>New tags that you’ve probably noticed include the <code>&lt;section&gt;</code> and <code>&lt;aside&gt;</code> tags. There’s also an <code>&lt;article&gt;</code> tag nested inside the section, and a <code>&lt;footer&gt;</code> tag as well.</p>
<p>First off, the section tag is defined as “The section element represents a generic document or application section. A section, in this context, is a thematic grouping of content, typically with a heading”. Since the <code>&lt;section&gt;</code> is going to encompass the articles titles and their summaries, <code>&lt;section&gt;</code> seems like a suitable tag to use here.</p>
<p>The <code>&lt;article&gt;</code> tag is defined as “self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable”, for example a blog post, so it’s perfect for the usage we’re going to be using it for. The <code>&lt;footer&gt;</code> tag inside that is defined as “The footer element represents a footer for its nearest ancestor sectioning content or sectioning root element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like”.</p>
<p>Finally, the <code>&lt;aside&gt;</code> tag is defined as “The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography”. This is great, because the sidebar is related to the content, while being separate.</p>
<p>After all that it’s just a case of adding the content. Here’s one I made earlier.</p>
<pre>
&lt;div id="content"&gt;
	&lt;section class="hfeed"&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt;&lt;a href="#"&gt;The Title&lt;/a&gt;&lt;/h2&gt;
				&lt;h3&gt;Posted by &lt;a class="author" href="#"&gt;Johnny&lt;/a&gt; on &lt;abbr class="updated published" title="20100228T15:08:00"&gt;February 28th&lt;/a&gt;&lt;/time&gt;&lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque feugiat hendrerit ante ut sagittis. Fusce blandit interdum tellus, non ornare massa luctus id. Proin lectus libero, dignissim sit amet dignissim in, facilisis sit amet tellus. Aenean sed felis a justo ultrices facilisis. Sed vehicula sagittis consequat. Donec iaculis lacinia augue eu aliquam. Vestibulum aliquet erat quis felis venenatis a ullamcorper diam semper. Donec vel neque quis sem fermentum tincidunt ac in mi. Pellentesque auctor consectetur justo, eu fermentum urna volutpat sit amet. Suspendisse lacus tellus, porta sed condimentum et, elementum vel diam. Donec at massa neque. Sed lobortis feugiat metus, tincidunt dignissim quam convallis sed.&lt;/p&gt;
			&lt;footer&gt;&lt;a href="#"&gt;Comment on this (5)&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Tweet this&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Stumble Upon&lt;/a&gt;&lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt;&lt;a href="#"&gt;The Title&lt;/a&gt;&lt;/h2&gt;
				&lt;h3&gt;Posted by &lt;a class="author" href="#"&gt;Johnny&lt;/a&gt; on &lt;abbr class="updated published" title="20100228T15:08:00"&gt;February 28th&lt;/a&gt;&lt;/time&gt;&lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque feugiat hendrerit ante ut sagittis. Fusce blandit interdum tellus, non ornare massa luctus id. Proin lectus libero, dignissim sit amet dignissim in, facilisis sit amet tellus. Aenean sed felis a justo ultrices facilisis. Sed vehicula sagittis consequat. Donec iaculis lacinia augue eu aliquam. Vestibulum aliquet erat quis felis venenatis a ullamcorper diam semper. Donec vel neque quis sem fermentum tincidunt ac in mi. Pellentesque auctor consectetur justo, eu fermentum urna volutpat sit amet. Suspendisse lacus tellus, porta sed condimentum et, elementum vel diam. Donec at massa neque. Sed lobortis feugiat metus, tincidunt dignissim quam convallis sed.&lt;/p&gt;
			&lt;footer&gt;&lt;a href="#"&gt;Comment on this (5)&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Tweet this&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Stumble Upon&lt;/a&gt;&lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt;&lt;a href="#"&gt;The Title&lt;/a&gt;&lt;/h2&gt;
				&lt;h3&gt;Posted by &lt;a class="author" href="#"&gt;Johnny&lt;/a&gt; on &lt;abbr class="updated published" title="20100228T15:08:00"&gt;February 28th&lt;/a&gt;&lt;/time&gt;&lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque feugiat hendrerit ante ut sagittis. Fusce blandit interdum tellus, non ornare massa luctus id. Proin lectus libero, dignissim sit amet dignissim in, facilisis sit amet tellus. Aenean sed felis a justo ultrices facilisis. Sed vehicula sagittis consequat. Donec iaculis lacinia augue eu aliquam. Vestibulum aliquet erat quis felis venenatis a ullamcorper diam semper. Donec vel neque quis sem fermentum tincidunt ac in mi. Pellentesque auctor consectetur justo, eu fermentum urna volutpat sit amet. Suspendisse lacus tellus, porta sed condimentum et, elementum vel diam. Donec at massa neque. Sed lobortis feugiat metus, tincidunt dignissim quam convallis sed.&lt;/p&gt;
			&lt;footer&gt;&lt;a href="#"&gt;Comment on this (5)&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Tweet this&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Stumble Upon&lt;/a&gt;&lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
	&lt;/section&gt;
	&lt;aside&gt;
		&lt;h2&gt;Archives&lt;/h2&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href="#"&gt;February 2010&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;January 2010&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;December 2009&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
		&lt;br /&gt;
		&lt;h2&gt;Categories&lt;/h2&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href="#"&gt;Tutorials&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;Articles&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;Resources&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;Inspiration&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
		&lt;br /&gt;
	&lt;/aside&gt;
&lt;/div&gt;</pre>
<p>Apart from the elements I mentioned, it’s all regular old HTML4, eh?</p>
<h2>The Footer</h2>
<p>The footer is a lot easier to make, and I think that generally I’ll leave this up to you to expand. For the time being though, I’ve decided to just go with a simple copyright. You could add more to these columns if you wanted.</p>
<pre>
&lt;footer id="main-footer"&gt;
	&lt;section id="footer-1"&gt;
		Copyright Webtint &amp;copy; 2010
	&lt;/section&gt;
	&lt;section id="footer-2"&gt;

	&lt;/section&gt;
&lt;/footer&gt;</pre>
<p>The final HTML code looks a bit like this:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;meta charset="utf-8" /&gt;

&lt;title&gt;HTML5 and CSS3 Layout&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;

&lt;!--[if IE]&gt;
&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="iehacks.css" /&gt;
&lt;![endif]--&gt;

&lt;!--[if lte IE 7]&gt;
&lt;link rel="stylesheet" type="text/css" href="ie67hacks.css" /&gt;
&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
	&amp;nbsp;
&lt;/div&gt;

&lt;header&gt;
	&lt;div id="logo"&gt;
		&lt;a href="#"&gt;&lt;img src="images/logo.gif" alt="Logo" /&gt;&lt;/a&gt;
	&lt;/div&gt;
	&lt;nav&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href="#"&gt;home&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;tutorials&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;resources&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;articles&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;forums&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;contact&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/nav&gt;
&lt;/header&gt;

&lt;div id="content"&gt;
	&lt;section class="hfeed"&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt;&lt;a href="#"&gt;The Title&lt;/a&gt;&lt;/h2&gt;
				&lt;h3&gt;Posted by &lt;a class="author" href="#"&gt;Johnny&lt;/a&gt; on &lt;abbr class="updated published" title="20100228T15:08:00"&gt;February 28th&lt;/a&gt;&lt;/time&gt;&lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque feugiat hendrerit ante ut sagittis. Fusce blandit interdum tellus, non ornare massa luctus id. Proin lectus libero, dignissim sit amet dignissim in, facilisis sit amet tellus. Aenean sed felis a justo ultrices facilisis. Sed vehicula sagittis consequat. Donec iaculis lacinia augue eu aliquam. Vestibulum aliquet erat quis felis venenatis a ullamcorper diam semper. Donec vel neque quis sem fermentum tincidunt ac in mi. Pellentesque auctor consectetur justo, eu fermentum urna volutpat sit amet. Suspendisse lacus tellus, porta sed condimentum et, elementum vel diam. Donec at massa neque. Sed lobortis feugiat metus, tincidunt dignissim quam convallis sed.&lt;/p&gt;
			&lt;footer&gt;&lt;a href="#"&gt;Comment on this (5)&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Tweet this&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Stumble Upon&lt;/a&gt;&lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt;&lt;a href="#"&gt;The Title&lt;/a&gt;&lt;/h2&gt;
				&lt;h3&gt;Posted by &lt;a class="author" href="#"&gt;Johnny&lt;/a&gt; on &lt;abbr class="updated published" title="20100228T15:08:00"&gt;February 28th&lt;/a&gt;&lt;/time&gt;&lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque feugiat hendrerit ante ut sagittis. Fusce blandit interdum tellus, non ornare massa luctus id. Proin lectus libero, dignissim sit amet dignissim in, facilisis sit amet tellus. Aenean sed felis a justo ultrices facilisis. Sed vehicula sagittis consequat. Donec iaculis lacinia augue eu aliquam. Vestibulum aliquet erat quis felis venenatis a ullamcorper diam semper. Donec vel neque quis sem fermentum tincidunt ac in mi. Pellentesque auctor consectetur justo, eu fermentum urna volutpat sit amet. Suspendisse lacus tellus, porta sed condimentum et, elementum vel diam. Donec at massa neque. Sed lobortis feugiat metus, tincidunt dignissim quam convallis sed.&lt;/p&gt;
			&lt;footer&gt;&lt;a href="#"&gt;Comment on this (5)&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Tweet this&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Stumble Upon&lt;/a&gt;&lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
		&lt;article class="hentry"&gt;
			&lt;hgroup&gt;
				&lt;h2 class="entry-title"&gt;&lt;a href="#"&gt;The Title&lt;/a&gt;&lt;/h2&gt;
				&lt;h3&gt;Posted by &lt;a class="author" href="#"&gt;Johnny&lt;/a&gt; on &lt;abbr class="updated published" title="20100228T15:08:00"&gt;February 28th&lt;/a&gt;&lt;/time&gt;&lt;/h3&gt;
			&lt;/hgroup&gt;
			&lt;p class="entry-summary"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque feugiat hendrerit ante ut sagittis. Fusce blandit interdum tellus, non ornare massa luctus id. Proin lectus libero, dignissim sit amet dignissim in, facilisis sit amet tellus. Aenean sed felis a justo ultrices facilisis. Sed vehicula sagittis consequat. Donec iaculis lacinia augue eu aliquam. Vestibulum aliquet erat quis felis venenatis a ullamcorper diam semper. Donec vel neque quis sem fermentum tincidunt ac in mi. Pellentesque auctor consectetur justo, eu fermentum urna volutpat sit amet. Suspendisse lacus tellus, porta sed condimentum et, elementum vel diam. Donec at massa neque. Sed lobortis feugiat metus, tincidunt dignissim quam convallis sed.&lt;/p&gt;
			&lt;footer&gt;&lt;a href="#"&gt;Comment on this (5)&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Tweet this&lt;/a&gt;&amp;emsp;&amp;bull;&amp;emsp;&lt;a href="#"&gt;Stumble Upon&lt;/a&gt;&lt;/footer&gt;
			&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;
		&lt;/article&gt;
	&lt;/section&gt;
	&lt;aside&gt;
		&lt;h2&gt;Archives&lt;/h2&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href="#"&gt;February 2010&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;January 2010&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;December 2009&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
		&lt;br /&gt;
		&lt;h2&gt;Categories&lt;/h2&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href="#"&gt;Tutorials&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;Articles&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;Resources&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#"&gt;Inspiration&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
		&lt;br /&gt;
	&lt;/aside&gt;
&lt;/div&gt;
&lt;footer id="main-footer"&gt;
	&lt;section id="footer-1"&gt;
		Copyright Webtint &amp;copy; 2010
	&lt;/section&gt;
	&lt;section id="footer-2"&gt;

	&lt;/section&gt;
&lt;/footer&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<h1>Cascading Stylesheets Numero 3</h1>
<p>Now at the minute, if you go and look at your document, you’ll see that it isn’t looking like much, and that’s because we haven’t added any CSS yet. The CSS file I’ve compiled is very basic and simple, adding only the bare essentials in order to make it as compressed as possible. Here’s the full CSS file for your amusement:</p>
<pre>body {
	font-family: Arial, Helvetica, sans-serif;
	background: #f1f1f1;
	padding: 0;
	margin: 0;
	color: #222;
	font-size: 62.5%;

}

header {
	width: 960px;
	margin: 0px auto;
	display: block;

}
	#logo {
		padding: 35px 0px 35px 40px;
		background: #fff;

		-moz-border-radius: 0.8em;
		-webkit-border-radius: 0.8em;

	}
	#logo a:active {
		background: transparent !important;
	}

nav {
	width: 950px;
	margin: 0px auto;
	overflow: hidden;
	font-size: 2.0em;
	font-weight: bold;
	padding: 0px 0px 0px 10px;

	display: block;
}

	nav ul {
		padding: 0;
		margin: 0;
	}

	nav ul li {
		list-style: none;
		float: left;
		padding: 0px 35px 0px 10px;
	}
	nav a {
		text-decoration: none;
		color: #000 !important;
		display: block;
		padding: 20px;
	}
	nav a:hover {
		color: #444;
		background: #fff;
	}

#content {
	width: 960px;
	margin: 0px auto;

	display: -webkit-box;
	-webkit-box-orient: horizontal;

	font-size: 1.4em;

}

footer {
	display: block;
}
	#main-footer {
		width: 960px;
		margin: 0px auto;
		padding: 15px;
		font-size: 1.8em;
		font-weight: bold;
		text-align: center;
	}

.hfeed, x:-moz-any-link, x:only-child {
	float: left;
}

aside, x:-moz-any-link, x:only-child {
	float: right;
}

article {
	text-align: justify;
	line-height: 1.5em;
	color: #222;

	display: block;
}

#main-content, .hfeed {
	padding: 10px 20px 20px 40px;
	width: 500px;
	background: #fff;

	-moz-border-radius-bottomleft: 0.8em;
	-webkit-border-bottom-left-radius: 0.8em;
	-moz-border-radius-topleft: 0.8em;
	-webkit-border-top-left-radius: 0.8em;

	display: block;

}

aside {
	padding: 10px 20px 20px 40px;
	width: 340px;
	background: #fff;

	-webkit-border-bottom-right-radius: 0.8em;
	-moz-border-radius-bottomright: 0.8em;
	-webkit-border-top-right-radius: 0.8em;
	-moz-border-radius-topright: 0.8em;

	display: block;

}
	aside ul {
		list-style: none;
		padding: 0px 0px 0px 6px;
	}

	aside ul li {
		line-height: 1.5em;
		font-size: 1.2em;
		border-bottom: 1px dotted #d9d9d9;
	}
	aside ul li a {
		padding: 10px 0px 10px 10px;
		display: block;
		font-weight: bold;
	}
	aside ul li a:hover {
		background: #f1f7f9;
	}

/* Some Headings for You */
h1 { font-size: 3.0em; }
h2 { font-size: 2.2em; }
h3 { font-size: 1.6em; }
h4 { font-size: 1.2em; }
h5 { font-size: 1.0em; }
h6 { font-size: 0.8em; }

hgroup h3, hgroup h3 a { color: #9aa8ad !important; }
hgroup h1, hgroup h1 a { color: #51add3 !important; }
h3 a { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { line-height: 0.5em; }

a {
	color: #2a708e;
	text-decoration: none;
}

a img {
	border: 0;
}

a:visited { color: #104258; }
a:active { background: #eaf7fc; }
a:hover { color: #0c1e2f; }

hr {
	border-bottom: 0px;
	border-left: 0px;
	border-right: 0px;
	border-top: 1px dotted #d9d9d9;
}

.floatleft {
	float: left;
}

.floatright {
	float: right;
}</pre>
<p>You may have noticed the few lines that go like this:</p>
<pre>.hfeed, x:-moz-any-link, x:only-child {
	float: left;
}

aside, x:-moz-any-link, x:only-child {
	float: right;
}</pre>
<p>These are firefox hacks, as firefox was handling the flexible box model in a weird way, so I decided just to use the old fashioned way, and use floats. <a href="http://webtint.net/tutorials/future-of-css-the-flexible-box-model/">Speaking of the flexible box model, click here to learn more about it</a>. Since the flexible box model has only been implemented in webkit browsers in my CSS, the only references you’ll see to it are these:</p>
<pre>	display: -webkit-box;
	-webkit-box-orient: horizontal;</pre>
<p>Another CSS3 feature I’ve included is rounded corners, which you may see floating about the script in forms like this:</p>
<pre>	-webkit-border-bottom-right-radius: 0.8em;
	-moz-border-radius-bottomright: 0.8em;
	-webkit-border-top-right-radius: 0.8em;
	-moz-border-radius-topright: 0.8em;</pre>
<p>Rounded corners are only really supported in Firefox and Webkit at the minute, so that’s the only places they’ll work. Another thing you might notice is that on all the new HTML5 tags, I’ve added <code>display: block;</code>. This is because firefox (again) was acting up and this seemed to remedy the problem. This leads us on to our next problem. <strong><em>Internet Explorer</em></strong></p>
<h2>Internet Explorer Hacks</h2>
<p>You might remember earlier that we included some links to stylesheets for IE hacks. You’re going to want to create those files now. A lot of you may not know this, but I have a great disdain for all things Internet Explorer, mainly because of it’s awful support for web technologies. So lets try and fix that up with a little CSS magic.</p>
<p>In the iehacks.css file, add this:</p>
<pre>#content {
	background: url(images/spacer.gif) repeat;
}

aside {
	float: right;
	padding-top: 40px;
}

.hfeed {
	float: left;
	padding-top: 40px;
}

hr {
	border-bottom: 1px solid #fff !important;
	border-left: 1px solid #fff !important;
	border-right: 1px solid #fff !important;
}</pre>
<p>This is just to fix a few problems with alignment and all that. This applies to all versions of IE. The spacer.gif image is a 1×1px white square. You might want to make that or <a href="http://webtint.net/spacer.gif">save it from here</a>. After that, open up ie67hacks.css and add the following:</p>
<pre>aside ul li {
	position: relative;
	right: 40px;

}</pre>
<p>Again, alignment issues. After that it’s just a case of putting it all together and hoping it stays put. For all you out there who don’t want to go to the bother of picking things out from this article, I’ve stuck together a demo and a downloadable zip for you below.</p>
<p><a href="http://webtint.net/webtint.net/filebank/html5css3.zip"><img class="no-img" src="http://webtint.net/download.gif" alt="download" /></a><a href="http://webtint.net/filebank/html5css3/"><img class="no-img" src="http://webtint.net/demo.gif" alt="demo" /></a><img src="http://feeds.feedburner.com/~r/Webtint/~4/SXkV9lVgrvs" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/avi/" title="avi" rel="tag">avi</a>, <a href="http://xguiden.dk/tag/chrome/" title="Chrome" rel="tag">Chrome</a>, <a href="http://xguiden.dk/tag/counter/" title="counter" rel="tag">counter</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/css3/" title="css3" rel="tag">css3</a>, <a href="http://xguiden.dk/tag/design/" title="design" rel="tag">design</a>, <a href="http://xguiden.dk/tag/doctype/" title="DOCTYPE" rel="tag">DOCTYPE</a>, <a href="http://xguiden.dk/tag/fil/" title="fil" rel="tag">fil</a>, <a href="http://xguiden.dk/tag/firefox/" title="FireFox" rel="tag">FireFox</a>, <a href="http://xguiden.dk/tag/fix/" title="fix" rel="tag">fix</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/header/" title="Header" rel="tag">Header</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/html5/" title="html5" rel="tag">html5</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/images/" title="images" rel="tag">images</a>, <a href="http://xguiden.dk/tag/internet/" title="internet" rel="tag">internet</a>, <a href="http://xguiden.dk/tag/internet-explorer/" title="Internet Explorer" rel="tag">Internet Explorer</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/meta/" title="META" rel="tag">META</a>, <a href="http://xguiden.dk/tag/mod/" title="Mod" rel="tag">Mod</a>, <a href="http://xguiden.dk/tag/over/" title="Over" rel="tag">Over</a>, <a href="http://xguiden.dk/tag/porte/" title="porte" rel="tag">porte</a>, <a href="http://xguiden.dk/tag/post/" title="POST" rel="tag">POST</a>, <a href="http://xguiden.dk/tag/reference/" title="reference" rel="tag">reference</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/source/" title="Source" rel="tag">Source</a>, <a href="http://xguiden.dk/tag/switch/" title="switch" rel="tag">switch</a>, <a href="http://xguiden.dk/tag/table/" title="table" rel="tag">table</a>, <a href="http://xguiden.dk/tag/tag/" title="tag" rel="tag">tag</a>, <a href="http://xguiden.dk/tag/tags/" title="tags" rel="tag">tags</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a>, <a href="http://xguiden.dk/tag/transparent/" title="Transparent" rel="tag">Transparent</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a>, <a href="http://xguiden.dk/tag/url/" title="URL" rel="tag">URL</a>, <a href="http://xguiden.dk/tag/wanted/" title="Wanted" rel="tag">Wanted</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/03/08/design-and-code-a-cool-iphone-app-website-in-html5/" title="Design and Code a Cool iPhone App Website in HTML5 (08/03/2010)">Design and Code a Cool iPhone App Website in HTML5</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/18/coding-a-css3-html5-one-page-website-template/" title="Coding a CSS3 &amp; HTML5 One-Page Website Template (18/02/2010)">Coding a CSS3 &amp; HTML5 One-Page Website Template</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/how-to-make-a-css-sprite-powered-menu/" title="How to Make a CSS Sprite Powered Menu (13/02/2010)">How to Make a CSS Sprite Powered Menu</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/protect-your-flash-files-from-decompilers-by-using-encryption/" title="Protect Your Flash Files From Decompilers by Using Encryption (13/02/2010)">Protect Your Flash Files From Decompilers by Using Encryption</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sanitize Database Inputs</title>
		<link>http://xguiden.dk/2010/03/03/sanitize-database%c2%a0inputs/</link>
		<comments>http://xguiden.dk/2010/03/03/sanitize-database%c2%a0inputs/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 21:48:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[PHP/Mysql]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5371</guid>
		<description><![CDATA[1) Function for stripping out malicious bits
&#60;?php
function cleanInput($input) { $search = array( '@&#60;script[^&#62;]*?&#62;.*?&#60;/script&#62;@si', // Strip out javascript '@&#60;[\/\!]*?[^&#60;&#62;]*?&#62;@si', // Strip out HTML tags '@&#60;style[^&#62;]*?&#62;.*?&#60;/style&#62;@siU', // Strip style tags properly '@&#60;![\s\S]*?--[ \t\n\r]*&#62;@' // Strip multi-line comments ); $output = preg_replace($search, '', $input); return $output; }
?&#62;
2) Sanitization function
Uses the function above, as well as adds slashes as [...]]]></description>
			<content:encoded><![CDATA[<h3>1) Function for stripping out malicious bits</h3>
<pre><code>&lt;?php
function cleanInput($input) { $search = array( '@&lt;script[^&gt;]*?&gt;.*?&lt;/script&gt;@si', // Strip out javascript '@&lt;[\/\!]*?[^&lt;&gt;]*?&gt;@si', // Strip out HTML tags '@&lt;style[^&gt;]*?&gt;.*?&lt;/style&gt;@siU', // Strip style tags properly '@&lt;![\s\S]*?--[ \t\n\r]*&gt;@' // Strip multi-line comments ); $output = preg_replace($search, '', $input); return $output; }
?&gt;</code></pre>
<h3>2) Sanitization function</h3>
<p>Uses the function above, as well as adds slashes as to not screw up database functions.</p>
<pre><code>&lt;?php
function sanitize($input) { if (is_array($input)) { foreach($input as $var=&gt;$val) { $output[$var] = sanitize($val); } } else { if (get_magic_quotes_gpc()) { $input = stripslashes($input); } $input = cleanInput($input); $output = mysql_real_escape_string($input); } return $output;
}
?&gt;</code></pre>
<h3>Usage</h3>
<pre><code>&lt;?php $bad_string = "Hi! &lt;script src='http://www.evilsite.com/bad_script.js'&gt;&lt;/script&gt; It's a good day!"; $good_string = sanitize($bad_string); // $good_string returns "Hi! It\'s a good day!" // Also use for getting POST/GET variables $_POST = sanitize($_POST); $_GET = sanitize($_GET);
?&gt;</code></pre>
<p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/yAxMsXKBJPM" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/database/" title="database" rel="tag">database</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/input/" title="input" rel="tag">input</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/mysql/" title="MYSQL" rel="tag">MYSQL</a>, <a href="http://xguiden.dk/tag/php/" title="php" rel="tag">php</a>, <a href="http://xguiden.dk/tag/post/" title="POST" rel="tag">POST</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/tag/" title="tag" rel="tag">tag</a>, <a href="http://xguiden.dk/tag/tags/" title="tags" rel="tag">tags</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/02/13/ajax-enabled-sticky-notes-with-php-and-jquery/" title="AJAX-enabled Sticky Notes With PHP and jQuery (13/02/2010)">AJAX-enabled Sticky Notes With PHP and jQuery</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/ajax-user-poll-using-jquery-and-php/" title="AJAX User Poll Using jQuery and PHP (13/02/2010)">AJAX User Poll Using jQuery and PHP</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/25/php-and-mysql-file-download-counter/" title="PHP and MySQL File Download Counter (25/02/2010)">PHP and MySQL File Download Counter</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/big-html-tutorial-reference/" title="Big HTML Tutorial &amp; Reference (13/02/2010)">Big HTML Tutorial &amp; Reference</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/18/make-your-mootools-code-shorter-faster-and-stronger/" title="Make your MooTools Code Shorter, Faster, and Stronger (18/02/2010)">Make your MooTools Code Shorter, Faster, and Stronger</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/03/03/sanitize-database%c2%a0inputs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and MySQL File Download Counter</title>
		<link>http://xguiden.dk/2010/02/25/php-and-mysql-file-download-counter/</link>
		<comments>http://xguiden.dk/2010/02/25/php-and-mysql-file-download-counter/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 17:06:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[PHP/Mysql]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[counter]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Gradient]]></category>
		<category><![CDATA[Header]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[LP]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[valid]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5209</guid>
		<description><![CDATA[It has been a while since we’ve done a proper PHP &#38; MySQL tutorial here, So today we are creating a simple, yet robust, file download tracker.
Each file will have a corresponding row in the database, where the total number of downloads is saved. PHP will update the MySQL database and redirect the visitors to [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a while since we’ve done a proper PHP &amp; MySQL tutorial here, So today we are creating a simple, yet robust, file download tracker.</p>
<p>Each file will have a corresponding row in the database, where the total number of downloads is saved. PHP will update the MySQL database and redirect the visitors to the appropriate files.</p>
<p>To track the number of downloads, you just need to upload your files to the <strong>files</strong> folder, and use a special URL to access them.</p>
<h3>Step 1 – XHTML</h3>
<p>The first step is to lay down the XHTML markup of the tracker.  It is pretty straightforward – we have the <strong>file-manager</strong> div, which contains an <strong>unordered list</strong> with each file as a <strong>li</strong> element.</p>
<p>The files, that are going to be tracked, are put into the <strong>files</strong> folder in the script root directory (you can see how the file structure is organized in  the demonstration zip file). PHP then loops through all the files and adds each one as a separate <strong>li</strong> element to the unordered list.</p>
<h4>demo.php</h4>
<pre>&lt;div id="file-manager"&gt;

	&lt;ul class="manager"&gt;

		&lt;!-- The LI items are generated by php --&gt;
		&lt;li&gt;&lt;a href="download.php?file=photoShoot-1.0.zip"&gt;photoShoot-1.0.zip
			&lt;span class="download-count" title="Times Downloaded"&gt;0&lt;/span&gt; &lt;span class="download-label"&gt;download&lt;/span&gt;&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;

&lt;/div&gt;
</pre>
<p>Notice the <strong>href </strong>attribute of the hyperlink – it passes  the name of the file as a parameter to <strong>download.php</strong>. This is where the download tracking happens, as you will see in a moment.</p>
<p>You are not limited to this interface in order to provide  download tracking – you can just post the links to <strong>download.php</strong> in your  blog posts or site pages, and all downloads will be correctly tracked.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i11.png"><img class="size-full wp-image-721" src="http://tutorialzine.com/wp-content/uploads/2010/02/i11.png" alt="Download Counter Interface" width="620" height="460" /></a>Download Counter Interface</p>
</div>
<h3>Step 2 – CSS</h3>
<p>With the XHTML markup in place, we can now concentrate on the presentation side of script. The CSS rules below target the <strong>file-manager</strong> div by <strong>id</strong> (with the <strong>hash symbol</strong>), as it is present only once in the page, and the rest of the elements by <strong>class names</strong>.</p>
<h4>styles.css</h4>
<pre>#file-manager{
	background-color:#EEE;
	border:1px solid #DDD;
	margin:50px auto;
	padding:10px;
	width:400px;
}

ul.manager li{
	background:url("img/bg_gradient.gif") repeat-x center bottom #F5F5F5;
	border:1px solid #DDD;
	border-top-color:#FFF;

	list-style:none;
	position:relative;
}

ul.manager li a{
	display:block;
	padding:8px;
}

ul.manager li a:hover .download-label{
	/* When a list is hovered over, show the download green text inside it: */
	display:block;
}

span.download-label{
	background-color:#64B126;
	border:1px solid #4E9416;
	color:white;
	display:none;
	font-size:10px;
	padding:2px 4px;
	position:absolute;
	right:8px;
	text-decoration:none;
	text-shadow:0 0 1px #315D0D;
	top:6px;

	/* CSS3 Rounded Corners */

	-moz-border-radius:3px;
	-webkit-border-radius:3px;
	border-radius:3px;
}

span.download-count{
	color:#999;
	font-size:10px;
	padding:3px 5px;
	position:absolute;
	text-decoration:none;
}</pre>
<p>The interesting part here is that the download label is hidden by default with <strong>display:none</strong>. It is shown with <strong>display:block</strong> only when we are hovering over its parent <strong>&lt;a&gt;</strong> element, and thus the right label is shown without a need for using JavaScript. A bit of <strong>CSS3 </strong>is also used as well to round the corners of the download label.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i21.png"><img class="size-full wp-image-722" src="http://tutorialzine.com/wp-content/uploads/2010/02/i21.png" alt="Hover State With CSS" width="620" height="260" /></a>Hover State With CSS</p>
</div>
<h3>Step 3 – PHP</h3>
<p>As mentioned earlier, PHP loops through the <strong>files</strong> folder, and outputs each file as a <strong>li</strong> element in the unordered list. Now lets take a closer look at how this happens.</p>
<h4>demo.php – Top Section</h4>
<pre>// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the DB connection file:
require 'connect.php';

$extension='';
$files_array = array();

/* Opening the thumbnail directory and looping through all the thumbs: */

$dir_handle = @opendir($directory) or die("There is an error with your file directory!");

while ($file = readdir($dir_handle))
{
	/* Skipping the system files: */
	if($file{0}=='.') continue;

	/* end() returns the last element of the array generated by the explode() function: */
	$extension = strtolower(end(explode('.',$file)));

	/* Skipping the php files: */
	if($extension == 'php') continue;

	$files_array[]=$file;
}

/* Sorting the files alphabetically */
sort($files_array,SORT_STRING);

$file_downloads=array();

$result = mysql_query("SELECT * FROM download_manager");

if(mysql_num_rows($result))
while($row=mysql_fetch_assoc($result))
{
	/* 	The key of the $file_downloads array will be the name of the file,
		and will contain the number of downloads: */

	$file_downloads[$row['filename']]=$row['downloads'];
}</pre>
<p>Notice how we are selecting all the rows from the <strong>download_manager </strong>table with <strong>mysql_query()</strong>, and later adding them to the <strong>$file_downloads</strong> array with the filename as a key to the number of downloads. This way, later in the code, we can write <strong>$file_downloads['archive.zip']</strong>, and output how many times this file has been downloaded.</p>
<p>You can see the code we use to generate the <strong>li</strong> items below.</p>
<h4>demo.php – Mid Section</h4>
<pre>foreach($files_array as $key=&gt;$val)
{
	echo '&lt;li&gt;&lt;a href="download.php?file='.urlencode($val).'"&gt;'.$val.'
		&lt;span class="download-count" title="Times Downloaded"&gt;'.(int)$file_downloads[$val].'&lt;/span&gt; &lt;span class="download-label"&gt;download&lt;/span&gt;&lt;/a&gt;
	&lt;/li&gt;';
}
</pre>
<p>It is simple as that – a <strong>foreach </strong>loop on the <strong>$files_array</strong> array, and an echo statement which prints all the markup to the page.</p>
<p>Now lets take a closer look at how exactly are the downloads tracked.</p>
<h4>download.php</h4>
<pre>// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the connection file:
require('connect.php');

if(!$_GET['file']) error('Missing parameter!');
if($_GET['file']{0}=='.') error('Wrong file!');

if(file_exists($directory.'/'.$_GET['file']))
{
	/* If the visitor is not a search engine, count the downoad: */
	if(!is_bot())
	mysql_query("	INSERT INTO download_manager SET filename='".mysql_real_escape_string($_GET['file'])."'
					ON DUPLICATE KEY UPDATE downloads=downloads+1");

	header("Location: ".$directory."/".$_GET['file']);
	exit;
}
else error("This file does not exist!");

/* Helper functions: */

function error($str)
{
	die($str);
}

function is_bot()
{
	/* This function will check whether the visitor is a search engine robot */

	$botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
	"looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
	"Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
	"crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
	"msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
	"Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
	"Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
	"Butterfly","Twitturls","Me.dium","Twiceler");

	foreach($botlist as $bot)
	{
		if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
		return true;	// Is a bot
	}

	return false;	// Not a bot
}
</pre>
<p>It is important to check if, by any chance, the visitor is a search engine robot scanning your links and not a real person. Robots are a good thing, as they get you included in services like Google Search, but in a situation such as this, can skew your download statistics. This is why the database row is updated only after the visitor passes the <strong>is_bot()</strong> validation.</p>
<h3>Step 4 – MySQL</h3>
<p>As mentioned in the previous step, the download count is stored as a row in the <strong>download_manager</strong> table in your MySQL database. First, lets explain how this particular query works:</p>
<h4>download.php</h4>
<pre>INSERT INTO download_manager SET filename='filename.doc'
ON DUPLICATE KEY UPDATE downloads=downloads+1</pre>
<p>It tells MySQL to insert a new row in the <strong>download_manager</strong> table, and set the <strong>filename</strong> field of the row to the value of the requested file for download. However, the <strong>filename</strong> field is defined as a <strong>unique index</strong> in the table. This means that a row can be inserted only once, otherwise a <strong>duplicate key error</strong> will occur.</p>
<p>This is where the second part of the query kicks in – <strong>ON DUPLICATE KEY UPDATE</strong> will tell MySQL to increment the downloads column by one if the file already exists in the database.</p>
<p>This way new files will be automatically inserted in the database the first time they are downloaded.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i31.png"><img class="size-full wp-image-727" src="http://tutorialzine.com/wp-content/uploads/2010/02/i31.png" alt="Structure of the download_manager Table" width="620" height="260" /></a>Structure of the download_manager Table</p>
</div>
<h3>Step 5 – jQuery</h3>
<p>To make the download tracking feel almost like real-time, it will be a nice addition to update the counter next to the file name once the user initiates the download. Otherwise they would have to initiate a page refresh so that new stats for the counter are shown.</p>
<p>We will achieve this with a little jQuery trick:</p>
<h4>script.js</h4>
<pre>$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	$('ul.manager a').click(function(){

		var countSpan = $('.download-count',this);
		countSpan.text( parseInt(countSpan.text())+1);
	});
});
</pre>
<p>We just assign a click handler to the links that point to the files, and every time one of them is clicked, we increment the number inside of the counter span tag.</p>
<h3>Step 6 – htaccess</h3>
<p>There is one more thing we need to do, before we call it a day. What <strong>download.php</strong> does is to  redirect the visitor to the requested file that was passed as a parameter. However you may have noticed that, for certain file types, the default browser behavior is to open them directly. We want to initiate a download instead. This is achieved with a couple of lines inside of a <strong>.htacess</strong> file, found in the <strong>files</strong> directory:</p>
<pre>&lt;Files *.*&gt;
ForceType application/octet-stream
&lt;/Files&gt;
</pre>
<p><strong>With this our File Download Counter is complete!</strong></p>
<h3>Conclusion</h3>
<p>To run the demo on your own server, you will need to recreate the <strong>download_manager</strong> table in a MySQL database you have access to. You can find the needed <strong>SQL</strong> code that will create the table for you in <strong>table.sql</strong>, which you can find in the download archive.</p>
<p>After this, just add your login details for the database (as provided by your webhost) to <strong>configuration.php</strong>.</p>
<p><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/3cczr6gT3A8" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/avi/" title="avi" rel="tag">avi</a>, <a href="http://xguiden.dk/tag/counter/" title="counter" rel="tag">counter</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/css3/" title="css3" rel="tag">css3</a>, <a href="http://xguiden.dk/tag/database/" title="database" rel="tag">database</a>, <a href="http://xguiden.dk/tag/fil/" title="fil" rel="tag">fil</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/gradient/" title="Gradient" rel="tag">Gradient</a>, <a href="http://xguiden.dk/tag/header/" title="Header" rel="tag">Header</a>, <a href="http://xguiden.dk/tag/help/" title="help" rel="tag">help</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/login/" title="login" rel="tag">login</a>, <a href="http://xguiden.dk/tag/lp/" title="LP" rel="tag">LP</a>, <a href="http://xguiden.dk/tag/mysql/" title="MYSQL" rel="tag">MYSQL</a>, <a href="http://xguiden.dk/tag/over/" title="Over" rel="tag">Over</a>, <a href="http://xguiden.dk/tag/php/" title="php" rel="tag">php</a>, <a href="http://xguiden.dk/tag/png/" title="png" rel="tag">png</a>, <a href="http://xguiden.dk/tag/post/" title="POST" rel="tag">POST</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/server/" title="Server" rel="tag">Server</a>, <a href="http://xguiden.dk/tag/system/" title="system" rel="tag">system</a>, <a href="http://xguiden.dk/tag/table/" title="table" rel="tag">table</a>, <a href="http://xguiden.dk/tag/tag/" title="tag" rel="tag">tag</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a>, <a href="http://xguiden.dk/tag/url/" title="URL" rel="tag">URL</a>, <a href="http://xguiden.dk/tag/valid/" title="valid" rel="tag">valid</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/02/13/ajax-enabled-sticky-notes-with-php-and-jquery/" title="AJAX-enabled Sticky Notes With PHP and jQuery (13/02/2010)">AJAX-enabled Sticky Notes With PHP and jQuery</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/16/how-to-build-an-unobtrusive-login-system-in-rails/" title="How to Build an Unobtrusive Login System in Rails (16/02/2010)">How to Build an Unobtrusive Login System in Rails</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/advanced-event-timeline-with-php-css-and-jquery/" title="Advanced Event Timeline With PHP, CSS and jQuery (13/02/2010)">Advanced Event Timeline With PHP, CSS and jQuery</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/halftone-navigation-menu-with-jquery-and-css3/" title="Halftone Navigation Menu With jQuery and CSS3 (13/02/2010)">Halftone Navigation Menu With jQuery and CSS3</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/02/25/php-and-mysql-file-download-counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Fundamentals: CSS 3 Transitions</title>
		<link>http://xguiden.dk/2010/02/25/css-fundamentals-css-3-transitions/</link>
		<comments>http://xguiden.dk/2010/02/25/css-fundamentals-css-3-transitions/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 17:05:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[CD]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[dvd]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mod]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Start]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5210</guid>
		<description><![CDATA[As CSS3 rolls out around the web, it is bringing some interesting new presentational techniques along with it. Today, we’ll review the basics of using CSS3 transitions and animations to add an extra layer of polish.
 

Tutorial Details

Program: A web browser that can utilise CSS3 transistions (Chrome or Safari)
Language: CSS
Difficulty: Easy
Estimated Completion Time: 30 min


Step [...]]]></description>
			<content:encoded><![CDATA[<p>As CSS3 rolls out around the web, it is bringing some interesting new presentational techniques along with it. Today, we’ll review the basics of using CSS3 transitions and animations to add an extra layer of polish.</p>
<p><span> </span></p>
<div><a href="http://nettuts.s3.cdn.plus.org/581_cssTransitions/demos.html.zip"><img src="http://net.tutsplus.com/wp-content/themes/nettuts/site_images/button_src_nm.jpg" alt="" /></a><a href="http://nettuts.s3.cdn.plus.org/581_cssTransitions/demos.html"><img src="http://net.tutsplus.com/wp-content/themes/nettuts/site_images/button_demo_nm.jpg" alt="" /></a></div>
<h3>Tutorial Details</h3>
<ul>
<li><strong>Program</strong>: A web browser that can utilise CSS3 transistions (Chrome or Safari)</li>
<li><strong>Language</strong>: CSS</li>
<li><strong>Difficulty:</strong> Easy</li>
<li><strong>Estimated Completion Time:</strong> 30 min</li>
</ul>
<div></div>
<h3>Step 1 – Link Transitions</h3>
<p>To begin, we’ll work with some basic techniques – firstly a simple change of text color when a user hovers over a specified element.</p>
<pre>a { color:#000; }
a:hover { color:#f00; }</pre>
<p>Here, we change the text color to red on hover. Now, with a little CSS3, we can create a much smoother look by gradually fading the color.</p>
<pre>a{
   color:#000;
   -webkit-transition:color 1s ease-in;
}
a:hover{color:#f00;}</pre>
<p>We’ve added the css property, -webkit-transition.  Note that the -webkit prefix specifies that this will only work in Webkit engines, or Safari and Chrome. Luckily, other modern browsers have their own implementations as well. A full statement covering all browsers might look similar to the following:</p>
<pre>a {
   color:#000;
   -webkit-transition:color 1s ease-in;
   -moz-transition:color 1s ease-in;
   -o-transition:color 1s ease-in;
   transition:color 1s ease-in;
}
</pre>
<p>Please note that, for this tutorial, we’ll be focusing exclusively on the webkit implementation. After the declaration of the property, we have the values “color 1s ease-in.” This is the shorthand declaration; the three values represent:</p>
<ol>
<li>the property to be transitioned</li>
<li>the duration of the transition</li>
<li>the type of transition</li>
</ol>
<p>In this case, we transition using ease-in, which will begin the transition slowly, and speed up into the transition.</p>
<h3>Step 2. Background Transitions</h3>
<p>Another basic use of changing states is to change the background of an input box on focus.</p>
<pre>input.ourInputBox:focus{
 -webkit-transition:background-color 0.5s linear;
 background:#CCC;
}
</pre>
<p>This time, we put the transition declaration into the hover state, so that we aren’t adding additional unnecessary classes to the CSS. We apply the transition once the input box acquires focus.</p>
<h3>Step 3 – Transitioning Multiple Properties</h3>
<p>CSS transitions are actually relatively straight forward to add to existing hover functionality, and give your<br />
site that extra polish for browsers that support CSS3.</p>
<p>To take things a step further, we can also transition multiple CSS properties using the longhand versions of the CSS3 transition.</p>
<pre>a.thebg {
 color:#000;
 background:#f00;
 padding:5px;
 -webkit-border-radius: 5px; 

 -webkit-transition-property:color, background;
 -webkit-transition-duration: 1s, 1s;
 -webkit-transition-timing-function: linear, ease-in;
} 

a.thebg:hover {
 color:#f00;
 background:#000;
}
</pre>
<p>This time, the background and text color changes on hover, so we can target both of these properties with our transition.<br />
We simply split the transition: first we have -webkit-transition-property and separate the different values with a comma. So we target the color and background properties, respectively.</p>
<pre>-webkit-transition-property:color, background;
</pre>
<p>Then we set the duration of the transition using:</p>
<pre>-webkit-transition-duration:1s, 1s;
</pre>
<p>These are referenced in the same order as the first statement; this time, however, both values are set to 1s.</p>
<p>Lastly, we set the timing function, and set two different values: the first, linear, relates to our first declared variable – color; and the second relates to the variable background.</p>
<p>So, we’ve set the color to a linear change over one second, and the background to ease-in over that same time period.</p>
<h3>Step 4 – Putting the Pieces Together</h3>
<p>CSS3 transitions start to come into their own when they’re combined with other new CSS properties.</p>
<p>You can review examples of using overlapping elements and transitions on <a href="http://forabeautifulweb.com/buy/dvds">Andy Clarke’s For a Beautiful Web</a>.</p>
<p>Let’s create a simple example of animating a pop out sign.</p>
<div><img src="http://nettuts.s3.cdn.plus.org/581_cssTransitions/signpost_ba.jpg" border="0" alt="" /></div>
<p>We first create the bounding box for the signpost, and give it a relative positioning context to ensure that we can<br />
position items absolutely within it.</p>
<pre>#signpost{
 width:60px;
 height:196px;
 position:relative;
}
</pre>
<p>Now we place the box on the page and put the pieces of our sign within it.</p>
<pre>&lt;div id="signpost"&gt;
	&lt;img id="post" src="post.png"&gt;
	&lt;img id="sign" src="sign.png"&gt;
&lt;/div&gt;
</pre>
<p>Next, the post is positioned with a z-index of two, to place it on top of the sign.</p>
<pre>#post{
 width:79px;
 height:196px;
 z-index:2;
 position:relative;
}
</pre>
<p>Now, we add in the sign, positioned underneath the post, and rotate it with the CSS3 transform property.</p>
<pre>#sign{
 height:46px;
 width:80px;
 position:absolute;
 top:10;
 left:60;
 -webkit-transform-origin:0 0;
 -webkit-transform: rotate(86deg);
 z-index:1;
 -webkit-transition:-webkit-transform 0.5s ease-in-out;
}</pre>
<p>The sign is rotated using -webkit-transform: rotate(86deg), and is positioned under the post. To ensure that the sign rotates around the proper point, we must change the <strong>transform origin</strong> to the top left corner: 0, 0.</p>
<div><img src="http://nettuts.s3.cdn.plus.org/581_cssTransitions/changeoforigin.jpg" border="0" alt="" /></div>
<p>We set the transition to change the -webkit-transform property over 0.5s with an ease-in-out profile, and on hover, we rotate the sign back to its original orientation.</p>
<pre>#signpost:hover #sign{
	-webkit-transform:rotate(0deg);
}
</pre>
<p>We do this on the containing #signpost:hover rather than on the hover of the #sign itself.</p>
<h3>Step 5 – Introducing Animations</h3>
<div><img src="http://nettuts.s3.cdn.plus.org/581_cssTransitions/circles.jpg" border="0" alt="" /></div>
<p>We can now tie all of this together, using webkit animations, which give us the power to carry out things such as continuous rotation.</p>
<p>We begin by creating two circle images, and positioning them inside a containing div – as we did with the signpost above.</p>
<pre>&lt;div id="circles"&gt;
	&lt;img src="outer.png" width="180" height="180" class="outercircle"/&gt;
	&lt;img src="middle.png" width="90" height="90" class="middlecircle"/&gt;
&lt;/div&gt;
</pre>
<pre>#circles{
	width:180px;
	height:180px;
	position:relative;
}
.outercircle{
	width:180px;
	height:180px;
	position:absolute;
	z-index:1;
	top:0:
	left:0;
}
.middlecircle{
	width:90px;
	height:90px;
	position:absolute;
	z-index:3;
	top:45px;
	left:45px;
}
</pre>
<p>Now we need to define the animations; we’ll spin the circles in opposite directions, so we need to set up two animations.</p>
<pre>@-webkit-keyframes spin {
from {
	-webkit-transform: rotate(0deg);
}
to {
	-webkit-transform: rotate(360deg);
	}
}

@-webkit-keyframes spinrev {
from {
	-webkit-transform: rotate(0deg);
	}
to {
	-webkit-transform: rotate(-360deg);
	}
}
</pre>
<p>The animation is given a name for reference, in this case “spin” and “spinrev.” Then, we assign them a <em>to</em> and <em>from</em> value; so we rotate the image from<br />
0 deg to 360 deg using webkit transform, and to -360 for the reverse.</p>
<p>Now we assign this animation to the hover states. Note that, if we assigned it to the normal state, the animation would run immediately when the page is loaded.</p>
<pre>#circles:hover .outercircle {
	-webkit-animation-name: spin;
	-webkit-animation-iteration-count: infinite;
	-webkit-animation-timing-function: linear;
	-webkit-animation-duration: 10s;
}	

#circles:hover .middlecircle{
	-webkit-animation-name: spinrev;
	-webkit-animation-iteration-count: infinite;
	-webkit-animation-timing-function: linear;
	-webkit-animation-duration: 5s;
}
</pre>
<p>We reference the animation name we created earlier (-webkit-animation-name: spin;). Then, we declare the number of times we want the animation to run (-webkit-animation-iteration-count: infinite;).<br />
In this case, infinite will keep it going round and round whilst the #circles div is hovered upon.</p>
<p>We next set the timing function (-webkit-animation-timing-function: linear;), and, finally, we set a duration for each iteration – in this case, it will be ten seconds (-webkit-animation-duration: 10s;), and five for a complete revolution.</p>
<h3>Step 6 – Graceful Degredation with Modenizr</h3>
<p>Once we have everything working, we should consider our users who are browsing without CSS3 capable web browsers. This is easily accomplished using a JavaScript library such as Modernizr, which adds classes to the HTML element relating to the browser capabilities.</p>
<p>Using the sign post example above, browsers that don’t support CSS transforms will not place the sign under the post correctly; so we can target these browsers and simply hide the sign until it is hovered over.</p>
<pre>.no-csstransforms #signpost #sign{
	display:none;
}
.no-csstransforms #signpost:hover #sign{
	display:block;
}
</pre>
<p>It’s as simple as linking to the Modernizr script, finding the appropriate class name, and then creating a separate CSS statement for that instance.</p>
<h3>Conclusion</h3>
<p>That’s all for now. I hope you enjoyed it! Let me know if you have any questions/comments below!</p>
<p><img src="http://feeds.feedburner.com/~r/nettuts/~4/5hsZlK90yog" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/animation/" title="animation" rel="tag">animation</a>, <a href="http://xguiden.dk/tag/cd/" title="CD" rel="tag">CD</a>, <a href="http://xguiden.dk/tag/chrome/" title="Chrome" rel="tag">Chrome</a>, <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/css3/" title="css3" rel="tag">css3</a>, <a href="http://xguiden.dk/tag/dvd/" title="dvd" rel="tag">dvd</a>, <a href="http://xguiden.dk/tag/fil/" title="fil" rel="tag">fil</a>, <a href="http://xguiden.dk/tag/fix/" title="fix" rel="tag">fix</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/image/" title="image" rel="tag">image</a>, <a href="http://xguiden.dk/tag/images/" title="images" rel="tag">images</a>, <a href="http://xguiden.dk/tag/input/" title="input" rel="tag">input</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/mod/" title="Mod" rel="tag">Mod</a>, <a href="http://xguiden.dk/tag/over/" title="Over" rel="tag">Over</a>, <a href="http://xguiden.dk/tag/png/" title="png" rel="tag">png</a>, <a href="http://xguiden.dk/tag/post/" title="POST" rel="tag">POST</a>, <a href="http://xguiden.dk/tag/reference/" title="reference" rel="tag">reference</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/start/" title="Start" rel="tag">Start</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a>, <a href="http://xguiden.dk/tag/tutorial/" title="tutorial" rel="tag">tutorial</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/02/13/jquery-ajax-validation-contact-form-with-modal-slide-in-transition/" title="jQuery AJAX Validation Contact Form with Modal + Slide-in Transition (13/02/2010)">jQuery AJAX Validation Contact Form with Modal + Slide-in Transition</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/animated-sharing-bar-with-jquery-and-css/" title="Animated Sharing Bar With jQuery and CSS (13/02/2010)">Animated Sharing Bar With jQuery and CSS</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/a-colorful-clock-with-css-and-jquery/" title="A Colorful Clock With CSS and jQuery (13/02/2010)">A Colorful Clock With CSS and jQuery</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/03/03/how-we%e2%80%99ll-be-building-websites-in-5-years-html5-and-css3-layout/" title="How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout (03/03/2010)">How We’ll be Building Websites in 5 years: HTML5 and CSS3 layout</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/02/25/css-fundamentals-css-3-transitions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validate Age</title>
		<link>http://xguiden.dk/2010/02/25/validate%c2%a0age/</link>
		<comments>http://xguiden.dk/2010/02/25/validate%c2%a0age/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 17:02:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[valid]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5216</guid>
		<description><![CDATA[This snippet presupposed an HTML form with and ID of “age-form” and three inputs (text or select) with the IDs “day”, “month”, and “year” respectively.
$("#age-form").submit(function(){ var day = $("#day").val(); var month = $("#month").val(); var year = $("#year").val(); var age = 18; var mydate = new Date(); mydate.setFullYear(year, month-1, day); var currdate = new Date(); currdate.setFullYear(currdate.getFullYear() [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet presupposed an HTML form with and ID of “age-form” and three inputs (text or select) with the IDs “day”, “month”, and “year” respectively.</p>
<pre><code>$("#age-form").submit(function(){ var day = $("#day").val(); var month = $("#month").val(); var year = $("#year").val(); var age = 18; var mydate = new Date(); mydate.setFullYear(year, month-1, day); var currdate = new Date(); currdate.setFullYear(currdate.getFullYear() - age); if ((currdate - mydate) &lt; 0){ alert("Sorry, only persons over the age of " + age + " may enter this site"); return false; } return true;
});</code></pre>
<p>You may wish to do something more elegant than an alert, and should also probably validate the form with server side code or else this protection only works for users with JavaScript enabled.</p>
<p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/wMbMgRrSc8M" alt="" width="1" height="1" /></p>

	Tags: <a href="http://xguiden.dk/tag/css/" title="CSS" rel="tag">CSS</a>, <a href="http://xguiden.dk/tag/get/" title="GET" rel="tag">GET</a>, <a href="http://xguiden.dk/tag/html/" title="HTML" rel="tag">HTML</a>, <a href="http://xguiden.dk/tag/input/" title="input" rel="tag">input</a>, <a href="http://xguiden.dk/tag/ip/" title="IP" rel="tag">IP</a>, <a href="http://xguiden.dk/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://xguiden.dk/tag/javascript/" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://xguiden.dk/tag/over/" title="Over" rel="tag">Over</a>, <a href="http://xguiden.dk/tag/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/server/" title="Server" rel="tag">Server</a>, <a href="http://xguiden.dk/tag/text/" title="text" rel="tag">text</a>, <a href="http://xguiden.dk/tag/valid/" title="valid" rel="tag">valid</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://xguiden.dk/2010/02/13/ajax-enabled-sticky-notes-with-php-and-jquery/" title="AJAX-enabled Sticky Notes With PHP and jQuery (13/02/2010)">AJAX-enabled Sticky Notes With PHP and jQuery</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/25/php-and-mysql-file-download-counter/" title="PHP and MySQL File Download Counter (25/02/2010)">PHP and MySQL File Download Counter</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/13/jquery-ajax-validation-contact-form-with-modal-slide-in-transition/" title="jQuery AJAX Validation Contact Form with Modal + Slide-in Transition (13/02/2010)">jQuery AJAX Validation Contact Form with Modal + Slide-in Transition</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/" title="How to Code up a Web Design from PSD to HTML (15/02/2010)">How to Code up a Web Design from PSD to HTML</a> (0)</li>
	<li><a href="http://xguiden.dk/2010/02/16/how-to-build-an-unobtrusive-login-system-in-rails/" title="How to Build an Unobtrusive Login System in Rails (16/02/2010)">How to Build an Unobtrusive Login System in Rails</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/02/25/validate%c2%a0age/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
