<?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; css3</title>
	<atom:link href="http://xguiden.dk/tag/css3/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>Design a Prettier Web Form with CSS 3</title>
		<link>http://xguiden.dk/2010/03/03/design-a-prettier-web-form-with-css-3/</link>
		<comments>http://xguiden.dk/2010/03/03/design-a-prettier-web-form-with-css-3/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 22:04:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[CD]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[FireFox]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Gradient]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[LP]]></category>
		<category><![CDATA[max]]></category>
		<category><![CDATA[Mount]]></category>
		<category><![CDATA[Outline]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[Start]]></category>
		<category><![CDATA[switch]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5329</guid>
		<description><![CDATA[Thanks to advanced CSS properties, such as gradients and shadows, it’s now quite easy to turn a dull web form into something beautiful – with minimal effort. I’ll show you how in today’s tutorial!
 

 


Our Final Product


Subtle background gradients give depth to the fields while shadows lift them from the page. Even more impressive is that [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to advanced CSS properties, such as gradients and shadows, it’s now quite easy to turn a dull web form into something beautiful – with minimal effort. I’ll show you how in today’s tutorial!</p>
<p><span> </span></p>
<div><a href="http://nettuts.s3.cdn.plus.org/584_form/demo.zip"><img src="http://net.tutsplus.com/wp-content/themes/nettuts/site_images/button_src_nm.jpg" alt="" /></a><br />
<a href="http://nettuts.s3.cdn.plus.org/584_form/demo.html"><img src="http://net.tutsplus.com/wp-content/themes/nettuts/site_images/button_demo_nm.jpg" alt="" /></a> </div>
<div>
<h4><a href="http://tutsplus.com/plus-content/nettuts/bonus-nettuts/design-a-prettier-web-form-with-css-3/"></a></p>
<p>Our Final Product</h4>
</div>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_final.png" border="0" alt="" /></div>
<p>Subtle background gradients give depth to the fields while shadows lift them from the page. Even more impressive is that this is done without any images at all.</p>
<p>By following this tutorial you will not only end up with a lightweight and beautiful form, you’ll also learn and understand new CSS3 techniques, such as <strong>box-shadow</strong>, <strong>gradients</strong>, <strong>opaque colors</strong>, and <strong>rounded corners</strong>.</p>
<h3>CSS3?</h3>
<p>CSS3 is the next generation of CSS that is currently under development, but that doesn’t stop browsers from already implementing most of the prominent features.</p>
<p>Full browser support:</p>
<ul>
<li><a href="http://www.google.com/chrome/" target="_blank">Google Chrome</a> (4.0)</li>
<li><a href="http://www.mozilla.com/firefox/" target="_blank">Mozilla Firefox</a> (3.6)</li>
<li><a href="http://www.apple.com/safari/" target="_blank">Safari</a> (4.0)</li>
</ul>
<p>Opera have support for CSS3 (except background gradients) in their next version (<a href="http://www.opera.com/developer/" target="_blank">10.50 Beta</a>).</p>
<p>Internet Explorer will have full CSS3 support with version 9.</p>
<p>The things you can do with CSS3 (shadows, gradients, round corners, animations, etc) all serve a purpose of creating beautiful effects without having to integrate images or scripts, resulting in quicker loading times.</p>
<h3>Step 1: The HTML</h3>
<p>Before we begin styling we need something to style, so here is the form.</p>
<pre>&lt;form class="form"&gt;

	&lt;p class="name"&gt;
		&lt;input type="text" name="name" id="name" /&gt;
		&lt;label for="name"&gt;Name&lt;/label&gt;
	&lt;/p&gt;

	&lt;p class="email"&gt;
		&lt;input type="text" name="email" id="email" /&gt;
		&lt;label for="email"&gt;E-mail&lt;/label&gt;
	&lt;/p&gt;

	&lt;p class="web"&gt;
		&lt;input type="text" name="web" id="web" /&gt;
		&lt;label for="web"&gt;Website&lt;/label&gt;
	&lt;/p&gt;

	&lt;p class="text"&gt;
		&lt;textarea name="text"&gt;&lt;/textarea&gt;
	&lt;/p&gt;

	&lt;p class="submit"&gt;
		&lt;input type="submit" value="Send" /&gt;
	&lt;/p&gt;

&lt;/form&gt;</pre>
<p>Each field is inside a paragraph with its own class, and the three first fields have a label explaining their use.</p>
<p>How does it look without any styling?</p>
<div>
<p><label for="name">Name</label></p>
<p><label for="email">E-mail</label></p>
<p><label for="web">Website</label></p>
<p><textarea name="text"></textarea></p>
</div>
<p>Functional, but dull. Let’s start pimping out this form.</p>
<h3>Step 2: Basic Styling</h3>
<p>Before we dive into the CSS3 techniques we need to create a basic layout for browsers that don’t yet support CSS3.</p>
<pre>input, textarea {
	padding: 9px;
	border: solid 1px #E5E5E5;
	outline: 0;
	font: normal 13px/100% Verdana, Tahoma, sans-serif;
	width: 200px;
	background: #FFFFFF;
	}

textarea {
	width: 400px;
	max-width: 400px;
	height: 150px;
	line-height: 150%;
	}

input:hover, textarea:hover,
input:focus, textarea:focus {
	border-color: #C9C9C9;
	}

.form label {
	margin-left: 10px;
	color: #999999;
	}

.submit input {
	width: auto;
	padding: 9px 15px;
	background: #617798;
	border: 0;
	font-size: 14px;
	color: #FFFFFF;
	}</pre>
<p>How does our effort look so far?</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_basic.png" border="0" alt="" /></div>
<p>Not too bad. Now, let’s begin our enhancements with the more advanced CSS3.</p>
<h3>Step 3: Box-shadow</h3>
<p>Box-shadow does exactly what it sounds like: creates a shadow around a box.</p>
<p>The syntax for box-shadow is fairly simple:</p>
<pre>box-shadow: &lt;color&gt; &lt;horizontal offset&gt; &lt;vertical offset&gt; &lt;blur&gt;;</pre>
<p><strong>Horizontal offset</strong> is the placement of the shadow from left to right. If you set it to “2px” the shadow will be 2 pixels to the right. <strong>Vertical offset</strong> is the same but up/down.</p>
<p><strong>Blur</strong> is simply the amount of blur the shadow will have, where 0 is minimum.</p>
<p>This is how our box-shadow will look like:</p>
<pre>input, textarea {
	box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	}</pre>
<p>Here we have three lines that look similar.</p>
<ul>
<li><strong>box-shadow</strong> is pure CSS3 and so far only used in Opera.</li>
<li><strong>-webkit-box-shadow</strong> is for browsers using the <a href="http://en.wikipedia.org/wiki/Webkit" target="_blank">Webkit engine</a>, like Chrome and Safari.</li>
<li><strong>-moz-box-shadow</strong> is for browsers using <a href="http://en.wikipedia.org/wiki/Mozilla_layout_engine" target="_blank">Mozilla’s Gecko engine</a>, like Firefox, Camino, Flock, and SeaMonkey.</li>
</ul>
<p>Until CSS3 becomes the standard, you have to use all three methods. Internet Explorer has their own weird way of doing things, and although it’s <a href="http://msdn.microsoft.com/en-us/library/ms532985(VS.85).aspx" target="_blank">capable of making a shadow</a> it will not look the way we want it. 3</p>
<p>You might notice that there was no normal RGB color used, this is because we’re using two CSS3 techniques on the same line: <strong>box-shadow</strong> and <strong>rgba</strong>.</p>
<p>RGBA (Red Green Blue Alpha) is, simply put, color with opacity.</p>
<p>The syntax for rgba is this:</p>
<pre>rgba(&lt;red&gt;,&lt;green&gt;,&lt;blue&gt;,&lt;opacity&gt;);</pre>
<p>It’s perfectly fine to use a light grey for the shadow’s color, but if you are using any other background than white it will look strange. An opaque black on the other hand will work well no matter what background.</p>
<p>So our box-shadow is black with 10% (0.1) opacity, no horizontal and vertical offset, and with a blur of 8 pixels. It will look like this:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_shadow.png" border="0" alt="" /></div>
<p>The keyword here is <strong>subtlety</strong>. If we apply too much shadow, it will look ugly; if we apply too little, it won’t have an effect. Basically, we don’t want anyone to notice the shadow, but still have it lift the fields from the page.</p>
<h3>Step 4: Background Gradient</h3>
<p>While the box-shadow syntax is easy to grasp, gradients are trickier. With CSS3 gradients, you can create some amazing shapes — <a href="http://hacks.mozilla.org/2009/11/css-gradients-firefox-36/" target="_blank">from dart boards to rainbows</a> — so as you can imagine it has a more complex syntax. Thankfully, we don’t need to code a rainbow today; we just need a straight linear gradient.</p>
<p><a href="http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Gradients/Gradients.html" target="_blank">Syntax for Webkit:</a></p>
<pre>-webkit-gradient( linear, &lt;start&gt;, &lt;end&gt;, from(&lt;color&gt;), to(&lt;color&gt;) )</pre>
<p><a href="https://developer.mozilla.org/en/CSS/-moz-linear-gradient" target="_blank">Syntax for Gecko:</a></p>
<pre>-moz-linear-gradient(&lt;start&gt; &lt;angle&gt;, &lt;color&gt;, &lt;color&gt;)</pre>
<p>As you can see, the methods are quite different, so this will require some explaining.</p>
<p><strong>Webkit</strong> gradients require a start point (X and Y), an end point (X and Y), a from-color, and a to-color. The angle is determined by where start and end are, and the gradient will be colored with the “from(color)” fading to “to(color)”.</p>
<p><strong>Gecko</strong> gradients, on the other hand, require only a start point (Y), and at least two colors. If you want a gradient going from top to bottom (90deg) you don’t need to assign an angle.</p>
<p>So to get a simple linear gradient from top to bottom – black to white – we would do like this:</p>
<pre>background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#FFFFFF));
background: -moz-linear-gradient(top, #000000, #FFFFFF);</pre>
<p>And it would appear like this:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/gradient_white-black.png" border="0" alt="" /></div>
<p>(I will continue to use the black color for demonstration; at the end, I’ll switch to the real color we will be using for the form.)</p>
<p>Now that we have the basics out of the way, we can start making the form look how we want. The first thing we want to do is limit the height of the gradient so that it looks the same for both input fields and textarea; otherwise the gradient would fill the entire height, like this:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/gradient_full-height.png" border="0" alt="" /></div>
<p>This is how we limit the background gradient to 25px in Webkit and Firefox:</p>
<pre>input, textarea {
	background: -webkit-gradient(linear, left top, left 25, from(#000000), to(#FFFFFF));
	background: -moz-linear-gradient(top, #000000, #FFFFFF 25px);
	}</pre>
<p>For Webkit, instead of setting the end point to “left bottom,” we set it to “left 25″, indicating it will end 25 pixels from the top.</p>
<p>For Gecko, we do the same thing by simply adding a “25px” value to the end color.</p>
<p>And the result is:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/gradient_limited-height.png" border="0" alt="" /></div>
<p>The second thing we want to do is create a thin white line at the top of the gradient, to give the subtle visual impression that the field is raised. How important can a single pixel be? Take a look at this article: <a href="http://webdesignledger.com/tips/adding-depth-with-pixel-perfect-line-work" target="_blank">Adding Depth with Pixel Perfect Line Work</a>.</p>
<p>To create this, we’ll need three points in the gradient. In the previous example, our gradient had two points: top and bottom (black→white). Here, we’ll add an additional point in between them (white→black→white).</p>
<p>To illustrate:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/gradient_stop-illustration.png" border="0" alt="" /></div>
<p>How do we do this?</p>
<pre>input, textarea {
	background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #000000), to(#FFFFFF));
	background: -moz-linear-gradient(top, #FFFFFF, #000000 1px, #FFFFFF 25px);
	}</pre>
<p>In Webkit we use the <strong>color-stop</strong> function, but unfortunately it doesn’t support values in pixels, only percentage. But thanks to paying attention to math in school we figure that 4% of 25px is 1px.</p>
<p>For Gecko, we simply add a third color between the first two and give it a “1px” value, indicating that it should end 1 pixel from the top.</p>
<p>The thin white line:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/gradient_stop.png" border="0" alt="" /></div>
<p>Now, let’s change the black color (#000000) to a more fitting light grey (#EEEEEE):</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_gradient.png" border="0" alt="" /></div>
<p>Just some small detail work remains.</p>
<p>First, we’ll create a darker shadow for the fields when the user hovers or selects it:</p>
<pre>input:hover, textarea:hover,
input:focus, textarea:focus {
	-webkit-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 8px;
	}</pre>
<p>It’s just an increase from 10% to 15%, but what we are after is, once again, subtlety.</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_shadow-hover.png" border="0" alt="" /></div>
<p>The last thing we do is create some rounded corners for the button3 to further make it stand out from the other elements:</p>
<pre>.submit input {
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	}</pre>
<p>The value is the radius the corners will be rounded by. The standard border-radius is intentionally left out since Opera seems to have some problem with it.</p>
<p>Result:</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_button.png" border="0" alt="" /></div>
<h3>Step 5: The Other Browsers</h3>
<p>Now we just need to take care of the browsers that don’t support CSS3 yet (IE), or only partly does (Opera).</p>
<p>We want the different versions (CSS3 and the normal) to look as similar as possible, and the simplest thing is to go back to the old way: images.</p>
<p>Simply take a screenshot of the beautiful CSS3 form and save a small portion of the gradient as an image.</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_photoshop1.png" border="0" alt="" /></div>
<p>Next, use it in the input and textarea as a background. As long as the CSS3 gradients comes after the background image, browsers that support CSS3 will ignore the image.</p>
<pre>input, textarea {
	background: #FFFFFF url('bg_form.png') left top repeat-x;
	}</pre>
<p>And now we are done! Enjoy your form and I hope you have learned something.</p>
<h3>Final Preview</h3>
<p>Chrome (4.0), Firefox (3.6), Safari (4.0):</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_final.png" border="0" alt="" /></div>
<p>Opera (10.50b):</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_final-opera.png" border="0" alt="" /></div>
<p>Internet Explorer (8):</p>
<div><img src="http://nettuts.s3.cdn.plus.org/584_form/form_final-ie.png" border="0" alt="" /></div>
<h3>Full CSS</h3>
<pre>input, textarea {
	padding: 9px;
	border: solid 1px #E5E5E5;
	outline: 0;
	font: normal 13px/100% Verdana, Tahoma, sans-serif;
	width: 200px;
	background: #FFFFFF url('bg_form.png') left top repeat-x;
	background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
	background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
	box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
	}

textarea {
	width: 400px;
	max-width: 400px;
	height: 150px;
	line-height: 150%;
	}

input:hover, textarea:hover,
input:focus, textarea:focus {
	border-color: #C9C9C9;
	-webkit-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 8px;
	}

.form label {
	margin-left: 10px;
	color: #999999;
	}

.submit input {
	width: auto;
	padding: 9px 15px;
	background: #617798;
	border: 0;
	font-size: 14px;
	color: #FFFFFF;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	}</pre>
<h3>Conclusion</h3>
<p>That’s all there is to it! With minimal effort, and the power of CSS 3, we’ve turned a bland and ordinary form into something beautiful. Thanks so much for reading, and feel free to ask any questions that you might have below.</p>

	Tags: <a href="http://xguiden.dk/tag/animation/" title="animation" rel="tag">animation</a>, <a href="http://xguiden.dk/tag/avi/" title="avi" rel="tag">avi</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/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/firefox/" title="FireFox" rel="tag">FireFox</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/guide/" title="guide" rel="tag">guide</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/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/lp/" title="LP" rel="tag">LP</a>, <a href="http://xguiden.dk/tag/max/" title="max" rel="tag">max</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/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/standard/" title="standard" rel="tag">standard</a>, <a href="http://xguiden.dk/tag/start/" title="Start" rel="tag">Start</a>, <a href="http://xguiden.dk/tag/switch/" title="switch" rel="tag">switch</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><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/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/02/13/personal-vcard-pt-2/" title="Personal vCard Pt.2 (13/02/2010)">Personal vCard Pt.2</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/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/03/design-a-prettier-web-form-with-css-3/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>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>Coding a CSS3 &amp; HTML5 One-Page Website Template</title>
		<link>http://xguiden.dk/2010/02/18/coding-a-css3-html5-one-page-website-template/</link>
		<comments>http://xguiden.dk/2010/02/18/coding-a-css3-html5-one-page-website-template/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 11:20:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[DOCTYPE]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Gradient]]></category>
		<category><![CDATA[Header]]></category>
		<category><![CDATA[HTML]]></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[Over]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[Start]]></category>
		<category><![CDATA[table]]></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=5132</guid>
		<description><![CDATA[Web development is an area in which you have to keep up with the latest technologies and techniques, so that you are at the top of your game.  And no wonder – this is an area which changes with an amazing pace. What is the standard now will be obsolete in just a couple of [...]]]></description>
			<content:encoded><![CDATA[<p>Web development is an area in which you have to keep up with the latest technologies and techniques, so that you are at the top of your game.  And no wonder – this is an area which changes with an amazing pace. What is the standard now will be obsolete in just a couple of years.</p>
<p>But changes do not come from nowhere. The early adopters are already using what we are going to use day-to-day a few years from now. One of these technologies is <strong>HTML5</strong> – the new version of the fundamental language of the web.</p>
<p>Today we are making a <strong>HTML5</strong> web template, using some of the new features brought by CSS3 and jQuery with the <strong>scrollTo</strong> plug-in. As HTML5 is still a work in progress, you can optionally download a <strong>XHTML version </strong>of the template <a href="http://tutorialzine.com/2010/02/free-xhtml-css3-website-template/" target="_blank">here</a>.</p>
<h3>Step 1 – The Design</h3>
<p>Every design process starts with an initial idea which you later build upon. At this stage designers usually go with programs such as Photoshop to work on the details and see how it will all look.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i1.png"><img class="size-full wp-image-672" src="http://tutorialzine.com/wp-content/uploads/2010/02/i1.png" alt="Photoshop Design" width="620" height="460" /></a>Photoshop Design</div>
<p>After this, the design is hand coded with HTML and CSS going hand by hand, moving from designing the background, colors and fonts, to detail work on the content section.</p>
<h3>Step 2 – HTML</h3>
<p>It is a good time to note, that <strong>HTML5</strong> is still a work in progress. It will remain so probably till around <strong>2022</strong> (I am absolutely serious about this). However some parts of the standard are complete, and can be used <strong>today</strong>.</p>
<p>In this tutorial, we are using a few of the tags introduced with this new version of HTML:</p>
<ul>
<li><strong>header</strong> – wraps your page header;</li>
<li><strong>footer</strong> – wraps your page footer;</li>
<li><strong>section</strong> – groups content into sections (e.g. main area, sidebar etc);</li>
<li><strong>article</strong> – separates the individual articles from the rest of the page;</li>
<li><strong>nav</strong> – contains your navigation menu;</li>
<li><strong>figure</strong> – usually contains an image used as an illustration for your article.</li>
</ul>
<p>These are used exactly as you would use normal divs. With the difference being that these tags organizes your page semantically. In other words, you can present your content in such a way, that the subject matter of your page can be more easily determined. As a result services, such as search engines, will bring you more targeted visitors and thus boost your revenue (and theirs actually).</p>
<p>However, there are some <strong>implications</strong> in using HTML5 today. One of the most notable is the IE family of browsers, which does not support these tags (it can be fixed with a simple JavaScript include file though). This is why you should base your decision for moving to HTML5 on your site’s audience. And just for this purpose, we are releasing a <a href="http://tutorialzine.com/2010/02/free-xhtml-css3-website-template/" target="_blank">pure XHTML version</a> of this template as well.</p>
<h4>template.html – Head section</h4>
<pre>&lt;!DOCTYPE html&gt; &lt;!-- The new doctype --&gt;

&lt;html&gt;
&lt;head&gt;

	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

	&lt;title&gt;Coding A CSS3 &amp;amp; HTML5 One Page Template | Tutorialzine demo&lt;/title&gt;

	&lt;link rel="stylesheet" type="text/css" href="styles.css" /&gt;

	&lt;!-- Internet Explorer HTML5 enabling script: --&gt;

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

			.clear {
				zoom: 1;
				display: block;
			}

		&lt;/style&gt;

	&lt;![endif]--&gt;

&lt;/head&gt;</pre>
<p>You can notice the new <strong>&lt;DOCTYPE&gt;</strong> at line one, which tells the browser that the page is created with the HTML5 standard. It is also much shorter and easier to remember than older doctypes.</p>
<p>After specifying the encoding of the document and the title, we move on to including a special JS file that will enable Internet Explorer (any version) to render HTML5 tags properly. Again, this means that if a visitor is using IE and has <strong>JavaScript disabled</strong>, the page is going to show up all <strong>messed up</strong>. This is why, depending on your audience, you should consider the regular XHTML version of this template, which works in <strong>any browser</strong> and is <a href="http://tutorialzine.com/2010/02/free-xhtml-css3-website-template/" target="_blank">released free for all our readers here</a>.</p>
<h4>template.html – Body Section</h4>
<pre>&lt;body&gt;

	&lt;section id="page"&gt; &lt;!-- Defining the #page section with the section tag --&gt;

	&lt;header&gt; &lt;!-- Defining the header section of the page with the appropriate tag --&gt;

		&lt;h1&gt;Your Logo&lt;/h1&gt;

		&lt;h3&gt;and a fancy slogan&lt;/h3&gt;

		&lt;nav class="clear"&gt; &lt;!-- The nav link semantically marks your main site navigation --&gt;

			&lt;ul&gt;

				&lt;li&gt;&lt;a href="#article1"&gt;Photoshoot&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#article2"&gt;Sweet Tabs&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#article3"&gt;Navigation Menu&lt;/a&gt;&lt;/li&gt;

			&lt;/ul&gt;

		&lt;/nav&gt;

	&lt;/header&gt;</pre>
<p>Here we use the new section tags, which divide your page into separate semantic sections. Outermost is the <strong>#page section</strong> which is set to a width of <strong>960px</strong> in the style sheet (a fairly standard width with older computer displays in mind). After this comes the header tag and the navigation tag.</p>
<p>Notice the <strong>href</strong> attributes of the links – the part after the hash symbol <strong>#</strong> corresponds to the <strong>ID</strong> of the <strong>article</strong> we want to scroll to.</p>
<h4>template.html – Article</h4>
<pre>	&lt;!-- Article 1 start --&gt;

	&lt;div class="line"&gt;&lt;/div&gt;  &lt;!-- Dividing line --&gt;

	&lt;article id="article1"&gt; &lt;!-- The new article tag. The id is supplied so it can be scrolled into view. --&gt;

		&lt;h2&gt;Photoshoot Effect&lt;/h2&gt;

		&lt;div class="line"&gt;&lt;/div&gt;

		&lt;div class="articleBody clear"&gt;

			&lt;figure&gt; &lt;!-- The figure tag marks data (usually an image) that is part of the article --&gt;

				&lt;a href="http://tutorialzine.com/2010/02/photo-shoot-css-jquery/"&gt;
					&lt;img src="http://tutorialzine.com/img/featured/641.jpg" width="620" height="340" /&gt;&lt;/a&gt;

			&lt;/figure&gt;

			&lt;p&gt;In this tutorial, we are creating a photo shoot effect with our just-released PhotoShoot jQuery plug-in. With it you can convert a regular div on the page into a photo shooting stage simulating a camera-like feel.&lt;/p&gt;

			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer luctus quam quis .... &lt;/p&gt;

		&lt;/div&gt;

	&lt;/article&gt;

	&lt;!-- Article 1 end --&gt;</pre>
<p>The markup above is shared between all of the articles. First is the dividing line (the best solution semantically would be an <strong>&lt;hr&gt;</strong> line, which in HTML5 has the added role of a logical diving element, but unfortunately it is impossible to style in a cross-browser fashion, so we will stick with a <strong>DIV</strong>). After this we have the new <strong>article</strong> tag, with a <strong>unique ID</strong>, which is used by the navigation to<strong> scroll the page</strong>.</p>
<p>Inside we have the title of the article, two paragraphs and the new figure tag, which marks the use of images in the article.</p>
<h4>template.html – Footer</h4>
<pre>		&lt;footer&gt; &lt;!-- Marking the footer section --&gt;

			&lt;div class="line"&gt;&lt;/div&gt;

			&lt;p&gt;Copyright 2010 - YourSite.com&lt;/p&gt; &lt;!-- Change the copyright notice --&gt;
			&lt;a href="#" class="up"&gt;Go UP&lt;/a&gt;
			&lt;a href="http://tutorialzine.com/" class="by"&gt;Template by Tutorialzine&lt;/a&gt;

		&lt;/footer&gt;

	&lt;/section&gt; &lt;!-- Closing the #page section --&gt;

	&lt;!-- JavaScript Includes --&gt;

	&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
	&lt;script src="jquery.scrollTo-1.4.2/jquery.scrollTo-min.js"&gt;&lt;/script&gt;
	&lt;script src="script.js"&gt;&lt;/script&gt;

	&lt;/body&gt;

&lt;/html&gt;</pre>
<p>Lastly, we have the <strong>footer</strong> tag, which does exactly what you expect it to do. At the bottom of the page are the rest of the JavaScript  includes, which add the <strong>jQuery library</strong> and the <strong>scrollTo</strong> plug-in, which we are going to use in the next steps.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i2.png"><img class="size-full wp-image-673" src="http://tutorialzine.com/wp-content/uploads/2010/02/i2.png" alt="HTML5 CSS3 Website Template" width="620" height="460" /></a>An HTML5 &amp; CSS3 Website Template</div>
<h3>Step 3 – CSS</h3>
<p>As we are using HTML5, we have to take some extra measures with the styling. The tags that this new version of HTML introduces, are not yet provided with a default styling. This is however easily fixed with a couple of lines of CSS code and the page works and looks as it is supposed to:</p>
<h4>styles.css – Part 1</h4>
<pre>header,footer,
article,section,
hgroup,nav,
figure{
	/* Giving a display value to the HTML5 rendered elements: */
	display:block;
}

article .line{
	/* The dividing line inside of the article is darker: */
	background-color:#15242a;
	border-bottom-color:#204656;
	margin:1.3em 0;
}

footer .line{
	margin:2em 0;
}

nav{
	background:url(img/gradient_light.jpg) repeat-x 50% 50% #f8f8f8;
	padding:0 5px;
	position:absolute;
	right:0;
	top:4em;

	border:1px solid #FCFCFC;

	-moz-box-shadow:0 1px 1px #333333;
	-webkit-box-shadow:0 1px 1px #333333;
	box-shadow:0 1px 1px #333333;
}

nav ul li{
	display:inline;
}

nav ul li a,
nav ul li a:visited{
	color:#565656;
	display:block;
	float:left;
	font-size:1.25em;
	font-weight:bold;
	margin:5px 2px;
	padding:7px 10px 4px;
	text-shadow:0 1px 1px white;
	text-transform:uppercase;
}

nav ul li a:hover{
	text-decoration:none;
	background-color:#f0f0f0;
}

nav, article, nav ul li a,figure{
	/* Applying CSS3 rounded corners: */
	-moz-border-radius:10px;
	-webkit-border-radius:10px;
	border-radius:10px;
}</pre>
<p>We basically need to set the <strong>display</strong> value of the new tags to <strong>block</strong>, as you can see from the first couple of lines. After this we can style them as we would with regular divs.</p>
<p>We style the horizontal lines, the articles and the navigation buttons, with the latter organized as an unordered list inside of the <strong>nav</strong> tag. At the bottom we assign the border-radius property for four different types of elements of once, which saves a lot of code.</p>
<h4>styles.css – Part 2</h4>
<pre>/* Article styles: */

#page{
	width:960px;
	margin:0 auto;
	position:relative;
}

article{
	background-color:#213E4A;
	margin:3em 0;
	padding:20px;

	text-shadow:0 2px 0 black;
}

figure{
	border:3px solid #142830;
	float:right;
	height:300px;
	margin-left:15px;
	overflow:hidden;
	width:500px;
}

figure:hover{
	-moz-box-shadow:0 0 2px #4D7788;
	-webkit-box-shadow:0 0 2px #4D7788;
	box-shadow:0 0 2px #4D7788;
}

figure img{
	margin-left:-60px;
}

/* Footer styling: */

footer{
	margin-bottom:30px;
	text-align:center;
	font-size:0.825em;
}

footer p{
	margin-bottom:-2.5em;
	position:relative;
}

footer a,footer a:visited{
	color:#cccccc;
	background-color:#213e4a;
	display:block;
	padding:2px 4px;
	z-index:100;
	position:relative;
}

footer a:hover{
	text-decoration:none;
	background-color:#142830;
}

footer a.by{
	float:left;

}

footer a.up{
	float:right;
}</pre>
<p>In the second part we apply more detailed styling to the elements. A width for the page section, a hover property for the figure tag and styles for the links inside of the footer. There are also a few styles that are not included here, but you can see them in <strong>styles.css</strong>.</p>
<p>Now lets continue with the next step.</p>
<div><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i3.png"><img class="size-full wp-image-674" src="http://tutorialzine.com/wp-content/uploads/2010/02/i3.png" alt="Structure Of The Page" width="620" height="460" /></a>Structure Of The Page &#8211; HTML5 Tags</div>
<h3>Step 4 – jQuery</h3>
<p>To enhance the template, we will create a smooth scrolling effect once a navigation link has been clicked using the <strong>scrollTo</strong> jQuery plug-in we included in the page earlier. To make it work we just need to loop through the links in the navigation bar (and the UP link in the footer) and assign an onclick event which will trigger the <strong>$.srollTo()</strong> function.</p>
<h4>script.js</h4>
<pre>$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	$('nav a,footer a.up').click(function(e){

		// If a link has been clicked, scroll the page to the link's hash target:

		$.scrollTo( this.hash || 0, 1500);
		e.preventDefault();
	});

});</pre>
<p><strong><em>With this our template is complete!</em></strong></p>
<h3>Wrapping it up</h3>
<p>In this tutorial we leveraged the new semantic features provided by HTML5 to design and code a one-page web template. You can use it for free both personally and commercially, providing you leave the back link intact.</p>
<p><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/y7bBsejKDeM" 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/avi/" title="avi" rel="tag">avi</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/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/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/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/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/script/" title="script" rel="tag">script</a>, <a href="http://xguiden.dk/tag/standard/" title="standard" rel="tag">standard</a>, <a href="http://xguiden.dk/tag/start/" title="Start" rel="tag">Start</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/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/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/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/13/personal-vcard-pt-2/" title="Personal vCard Pt.2 (13/02/2010)">Personal vCard Pt.2</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>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://xguiden.dk/2010/02/18/coding-a-css3-html5-one-page-website-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Future of CSS: The Flexible Box Model</title>
		<link>http://xguiden.dk/2010/02/18/future-of-css-the-flexible-box-model/</link>
		<comments>http://xguiden.dk/2010/02/18/future-of-css-the-flexible-box-model/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 11:18:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[FireFox]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Mod]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[porte]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[Start]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5133</guid>
		<description><![CDATA[Support
As always with this new fangled CSS, support is pretty thin on the ground. Here’s a list of the properties and how they’re supported, in no particular order.



 
Gecko
Firefox
Webkit
Chrome/Safari
Trident
Internet Explorer
Presto
Opera


box-flex
Yes*
Yes✝
No
No


box-direction
Yes*
Yes✝
No
No


box-align
Yes*
Yes✝
No
No


box-flex-group
Yes*
Yes✝
No
No


box-lines
Yes*
Yes✝
No
No


box-ordinal-group
Yes*
Yes✝
No
No


box-orient
Yes*
Yes✝
No
No


box-pack
Yes*
Yes✝
No
No




* Only Supported with the prefix -moz (i.e. -moz-box-pack
✝ Only Supported with the prefix -webkit (i.e. -webkit-box-pack)

‘course, as you’ve probably realised it wouldn’t have mattered what order [...]]]></description>
			<content:encoded><![CDATA[<div>Support</div>
<p>As always with this new fangled CSS, support is pretty thin on the ground. Here’s a list of the properties and how they’re supported, in no particular order.</p>
<table cellspacing="5" width="605">
<tbody>
<tr>
<td> </td>
<td>Gecko<br />
Firefox</td>
<td>Webkit<br />
Chrome/Safari</td>
<td>Trident<br />
Internet Explorer</td>
<td>Presto<br />
Opera</td>
</tr>
<tr>
<td>box-flex</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-direction</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-align</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-flex-group</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-lines</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-ordinal-group</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-orient</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>box-pack</td>
<td>Yes*</td>
<td>Yes<sup>✝</sup></td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
<p><code><br />
* Only Supported with the prefix -moz (i.e. -moz-box-pack<br />
<sup>✝</sup> Only Supported with the prefix -webkit (i.e. -webkit-box-pack)<br />
</code></p>
<p>‘course, as you’ve probably realised it wouldn’t have mattered what order they were in anyway, since only Firefox and Chrome/Safari support the flexible box model at this point. This is a bit troublesome, since we can’t go ahead and use this in all our projects because it’s not supported by Internet Explorer (&gt;60% of market) or Opera (about 2%). In the future though this is really gonna improve how we make websites (when it’s supported by everyone).</p>
<p>In fact the way that Gecko and Webkit support the box model is completely different, so I’ve tried to give you as much solid information as I can from observations on both platforms.<br />
<img src="http://webtint.net/wp-content/uploads/2010/02/0m.gif" alt="" width="580" /></p>
<h1>How it Works</h1>
<p>Nowadays websites are often split into many columns, to accomplish a sort of newspaper-esque layout. Of course, we can accomplish this with the float property in CSS2, but CSS2 really wasn’t designed with an easy way to make columns. Traditionally web designers would design columnar layouts like this:</p>
<pre>#left-column {
      float: left;
}

#right-column {
      float: left;
}</pre>
<h2>Initiating your Box</h2>
<p>With the flexible box model things are a little different, but different in a good way. Words can’t describe how wonderful I think this specification is, so I’ll use code instead. Here’s a piece of code that I want to <em>columnize</em>, so to say.</p>
<pre>&lt;div class="container"&gt;
	&lt;div class="blue"&gt;
		This is some content.
	&lt;/div&gt;
	&lt;div class="blue"&gt;
		Only there are four columns!
	&lt;/div&gt;
	&lt;div class="blue"&gt;
		Four columns!
	&lt;/div&gt;
	&lt;div class="blue"&gt;
		Amazing.
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>And here’s the CSS:</p>
<pre>.container {
        width: 1000px;

	display: -webkit-box;
	display: -moz-box;

	-webkit-box-orient: horizontal;
	-moz-box-orient: horizontal;

}

.blue {
	background: #357c96;
	font-weight: bold;
	margin: 2px;
	padding: 20px;
	color: #fff;
	font-family: Arial, sans-serif;
}</pre>
<p>It’s as easy as that! (It’ll be even easier when we don’t have to do browser specific elements). You can totally ignore the .blue class, that’s just some styling. The container class sets the display mode to box, and sets box-orient to horizontal. This gives you something like this:<br />
<img src="http://webtint.net/wp-content/uploads/2010/02/1m.gif" alt="" /></p>
<p>You can also set the box orient to vertical if you wish for vertically stacked divs.</p>
<h2>Box Flex</h2>
<p>As you probably have already figured out, the actual structure of these elements looks like this:<br />
<img src="http://webtint.net/wp-content/uploads/2010/02/2m.gif" alt="" /></p>
<p>As you can see there’s a bit of a gap at the end of the 4th column element. This is where the box model is so useful. Whereas before you would have to juggle around with pixels until you finally got a good combination where the columns filled the space. With the flexible box model you can stretch out certain elements to fill the space.</p>
<pre>.flexible {
        -webkit-box-flex: 1;
        -moz-box-flex: 1;
}</pre>
<p>If we were to add this flexible class to the 3rd column element, you would end up with this:<br />
<img src="http://webtint.net/wp-content/uploads/2010/02/3m.gif" alt="" /></p>
<p>The remaining space is divided amongst the elements by their box-flex. Since there is only one box-flex element, all the extra space is given to the element with a box-flex of 1. If you had 2 box-flex elements with a value of 1, the space would be distributed evenly between these two.</p>
<p>For instance, lets say you gave the first 2 column elements in our example the ‘flexible’ class. Both elements would have a box-flex value of 1, so you would end up with something like this:<br />
<img src="http://webtint.net/wp-content/uploads/2010/02/4m.gif" alt="" /></p>
<p>If you’re more mathematically minded you can think of it as if the two columns are in a 1:1 ratio, so the space is spread out in a 1:1 ratio.</p>
<p>So, for example, if there was 400px of extra space, each element would get an extra 200px. Similarly if one of the box-flex properties were 3, the two elements would be in a 3:1, so one box would get 300px extra, while the other would gain 100px. This allows you to easily expand your boxes to your needs.</p>
<h2>Orientation</h2>
<p>Orientation i another key element to the flexible box model. Lets take a look at our earlier example. We could reverse the order (so it would be going 4, 3, 2, 1 instead of 1, 2, 3, 4) by adding this to our container element:</p>
<pre>        -moz-box-direction: reverse;
        -webkit-box-direction: reverse;</pre>
<p>You can use the <strong>box-ordinal-group</strong> element to alter the position of columns too. Simply put, the element with the highest box-ordinal-group will be moved to the end. If you have set box-direction to reverse, the end will be the left hand side, otherwise the right hand side will be the end. An example of a box ordinal group may be as follows:</p>
<pre>        -moz-box-ordinal-group: 2;
        -webkit-box-ordinal-group: 2;</pre>
<h2>Alignment</h2>
<p>Aligning boxes is pretty easy to do. There are two properties you want to watch out for. <strong>box-align</strong> and <strong>box-pack</strong>.</p>
<p>If you have your boxes orientation set to horizontal, then <strong>box-align</strong> will decide how that element is aligned vertically inside your box. Similarly if it’s set to vertical, it will decide how its aligned horizontally. The <strong>box-pack</strong> element is the complete opposite, applying to horizontal when your box is orientated horizontally, and vertical when your box is orientated vertically. Using both you can center your box elements in any way you want when there’s some extra space left over.</p>
<h1>A Recap</h1>
<p>Here are all the elements again, their default properties and the properties you can apply to them.</p>
<table cellspacing="5" width="605">
<tbody>
<tr>
<td> </td>
<td>Default</td>
<td>Possible Values</td>
</tr>
<tr>
<td>box-flex</td>
<td>0.0</td>
<td>number</td>
</tr>
<tr>
<td>box-direction</td>
<td>normal</td>
<td>normal | reverse | inherit</td>
</tr>
<tr>
<td>box-align</td>
<td>stretch</td>
<td>start | end | center | baseline | stretch</td>
</tr>
<tr>
<td>box-flex-group</td>
<td>1</td>
<td>integer</td>
</tr>
<tr>
<td>box-lines</td>
<td>single</td>
<td>single | multiple</td>
</tr>
<tr>
<td>box-ordinal-group</td>
<td>1</td>
<td>integer</td>
</tr>
<tr>
<td>box-orient</td>
<td>inline-axis</td>
<td>horizontal | vertical | inline-axis* | block-axis* | inherit</td>
</tr>
<tr>
<td>box-pack</td>
<td>start</td>
<td>start | end | center | justify</td>
</tr>
</tbody>
</table>
<p><code>*inline-axis and *block-axis are equivalent to horizontal and vertical respectively.</code></p>
<p>And here’s a quick reference table so you can see what each element does.</p>
<table cellspacing="5" width="605">
<tbody>
<tr>
<td> </td>
<td>Function</td>
</tr>
<tr>
<td>box-flex</td>
<td>Allows the boxes children to “flex out” and expand into the space left over at the end. Can be put into a ratio by giving one element a box-flex of 2, and another a box-flex of 1, giving them a 2:1 ratio</td>
</tr>
<tr>
<td>box-direction</td>
<td>The direction the boxes children should go in. Normal or revere.</td>
</tr>
<tr>
<td>box-align</td>
<td>Set how the boxes children are aligned in the box. If the orientation i horizontal it will decide the alignment vertically and vice-versa</td>
</tr>
<tr>
<td>box-flex-group</td>
<td>Assign a group to flexible elements</td>
</tr>
<tr>
<td>box-lines</td>
<td>Normally the column will continue on forever in the orientation you chose. If you set box-lines to multiple, the columns will go onto a new line whenever it runs out of space in the parent box.</td>
</tr>
<tr>
<td>box-ordinal-group</td>
<td>Determines how the boxes children are ordered. A smaller box-ordinal-group will go to the beginning of the box, while a bigger one will go to the end. The start is the left if the direction is normal, and vice versa if it’s reverse.</td>
</tr>
<tr>
<td>box-orient</td>
<td>How the boxes children should be aligned. Horizontal to stack them horizontally, and vertical to stack them vertically.</td>
</tr>
<tr>
<td>box-pack</td>
<td>Sets the alignment of the box along the box-orient axis, so if box-orient is horizontal it will chose how the boxes children are aligned horizontally, and vice versa.</td>
</tr>
</tbody>
</table>
<h1>Where do I go from here?</h1>
<ul>
<li><a href="http://www.w3.org/TR/css3-flexbox/">W3C CSS3 Flexible Box Model Spec</a></li>
<li><a href="http://www.css3.info/">CSS3 Information</a></li>
</ul>
<p><img src="http://webtint.net/?ak_action=api_record_view&amp;id=3572&amp;type=feed" alt="" /></p>
<h1><img src="http://feeds.feedburner.com/~r/Webtint/~4/F842qgvZt24" alt="" width="1" height="1" /></h1>

	Tags: <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/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/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/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/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/reference/" title="reference" rel="tag">reference</a>, <a href="http://xguiden.dk/tag/start/" title="Start" rel="tag">Start</a>, <a href="http://xguiden.dk/tag/table/" title="table" rel="tag">table</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<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/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/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/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/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/18/future-of-css-the-flexible-box-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Code up a Web Design from PSD to HTML</title>
		<link>http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/</link>
		<comments>http://xguiden.dk/2010/02/15/how-to-code-up-a-web-design-from-psd-to-html/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 11:03:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Engelske guides]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[avi]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[DOCTYPE]]></category>
		<category><![CDATA[fil]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[Flash]]></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[images]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[LP]]></category>
		<category><![CDATA[META]]></category>
		<category><![CDATA[Mod]]></category>
		<category><![CDATA[Over]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[porte]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[Start]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[textur]]></category>
		<category><![CDATA[Transparent]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[valid]]></category>
		<category><![CDATA[Wanted]]></category>

		<guid isPermaLink="false">http://xguiden.dk/?p=5047</guid>
		<description><![CDATA[A couple of weeks back we went through the process of creating a gnarly snowboarding themed website design concept in Photoshop. The tutorial covered the process of designing our site concept from sketch to finished PSD design. Now, let’s take the design to the next step and code up a complete mockup in HTML and [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks back we went through the process of creating a gnarly snowboarding themed website design concept in Photoshop. The tutorial covered the process of designing our site concept from sketch to finished PSD design. Now, let’s take the design to the next step and code up a complete mockup in HTML and CSS, ensuring our code is semantic and standards compliant. We’ll then add some finishing touches with a spot of jQuery.</p>
<p><span> </span></p>
<h3>To refresh your memory</h3>
<p><a href="http://line25.com/tutorials/create-a-gnarly-snowboarding-themed-web-design"><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/concept.jpg" alt="See the making of the concept" /></a></p>
<p>Cast your mind back and you’ll remember we left off at the end of the post titled Create a Gnarly Snowboarding Themed Web Design with a finished PSD sporting a textured background, large feature area and a mix of text, images and video making up the main content area.</p>
<h3>Cutting up the PSD concept</h3>
<p>With our design being pretty design heavy, there’s a good selection of elements that will need exporting from the PSD. The first is the large textured background.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/export-select-bg.jpg" alt="Select the background texture" /></p>
<p>Disable all other layers then draw a large marquee across the design that includes all the textured elements and blue gradient. Press CMD+Shift+C to copy this selection, then paste in into a new document.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/export-bg.jpg" alt="Extend the background to accommodate large monitors" /></p>
<p>To take into consideration larger monitors, we need to make sure our design is wide enough not to be cropped off. A width of 2200px should be more than sufficient to accommodate even the larger of monitor setups. Select a portion of the gradient and press CMD-T to transform and stretch the background to fill the white space. Save this large image for the web, but take care to balance between file size and quality. With the image being super-sized, it’s important to carefully select the appropriate compression settings. My final file weighs in at 220kb, which is pretty heavy in normal circumstances, but considering that the rest of the design is quite lightweight, it’s a sacrifice that can be justified. <em>We could have made things much easier for ourselves by not including a gradient as well as a texture, this way we could set a smaller graphic in the center that fades out to a flat colour. (Or wait until the multiple backgrounds CSS3 property is more widely supported!)</em></p>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/export-logo.jpg" alt="Selecting the logo graphic" /></p>
<p>Continue selecting individual page elements with the marquee tool, pressing CMD-Shift-C to copy-merged then paste in a new document and export. Elements such as the logo, feature graphics, profile shots and every small icon needs saving as an individual graphic.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/export-button.jpg" alt="Exporting individual page items" /></p>
<p>Remember to choose the most appropriate file type and compression setting for each item. An element that is made up of flat colours will be more suited to PNG format. Elements that require a transparent background can be exported using the PNG-24 option.</p>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/images.jpg" alt="Overview of all image files" /></p>
<p>Once all of the images have been saved, you’re ready to move onto the HTML section of the website build.</p>
<h3>Building the HTML structure</h3>
<p>It’s always important to build the house before decorating the rooms, so we’ll begin by writing out the HTML structure of the website. We’ll base the HTML on the XHTML Strict Doctype and add the initial link to the stylesheet and a containing div to hold the content.</p>
<div>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;Snow Candy&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>
<h4>The header</h4>
<p>The structure for the header is pretty simple. We have our logo, which is set in a H1 and links back to the homepage. Our navigation is perfect for an unordered list, and each contains an anchor to the relevant page. A class of active will then allow us to target an individual page for highlighting the active page.</p>
<div>
<pre>&lt;div id="header"&gt;
	&lt;h1&gt;&lt;a href="#"&gt;Snow Candy&lt;/a&gt;&lt;/h1&gt;
	&lt;ul id="nav"&gt;
		&lt;li&gt;&lt;a href="#" class="active"&gt;Home&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#"&gt;Apparel&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#"&gt;Team&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#"&gt;Shop&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
</div>
<h4>The content</h4>
<p>Next we flesh out the bulk of the page content. The whole main area can be contained within a div with an ID of content. Within this we’ll start with the large feature graphics, an unordered list will once again be a handy element to use, as it allows us to easily list them out in sequence. Inside each list element is each image graphic, complete with a descriptive alt attribute.</p>
<div>
<pre>&lt;div id="content"&gt;
&lt;div id="features"&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href="#"&gt;&lt;img src="images/feature-1.jpg" alt="5th Annual Big Air Jam. 5th January 2010" /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#"&gt;&lt;img src="images/feature-2.jpg" alt="Salomon Shred Round One" /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#"&gt;&lt;img src="images/feature-3.jpg" alt="Snow Candy in S&amp;auml;len" /&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
</div>
<p>The design then splits into two columns, so we can add a div with a class of column ready for floating with CSS later. Within the featured video section I’ve embedded a cool snowboarding video from <a href="http://vimeo.com/3155182">Vimeo</a>, followed by the title and description, both set in natural header and paragraph tags. A paragraph tag with a class of “btn” will allow us to set up a global style for any button style objects, allowing some unique styling to be added. The actual Vimeo embedding code has been modified slightly to keep it valid within our Strict doctype.<em> </em></p>
<div>
<pre>&lt;div class="column"&gt;
	&lt;h2 class="featured-video"&gt;Featured Video&lt;/h2&gt;
	&lt;div class="video"&gt;
		&lt;object width="379" height="213" type="application/x-shockwave-flash" data="http://vimeo.com/moogaloop.swf?clip_id=3155182&amp;amp;server=vimeo.com&amp;amp;show_title=0&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00adef&amp;amp;fullscreen=1"&gt;
			&lt;param name="allowfullscreen" value="true" /&gt;
			&lt;param name="allowscriptaccess" value="always" /&gt;
			&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3155182&amp;amp;server=vimeo.com&amp;amp;show_title=0&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00adef&amp;amp;fullscreen=1" /&gt;
		&lt;/object&gt;
	&lt;/div&gt;

	&lt;h3&gt;&lt;a href="#"&gt;Snow Candy in S&amp;auml;len&lt;/a&gt;&lt;/h3&gt;
	&lt;p&gt;The Snow Candy team head to S&amp;auml;len to experience the local snow, attractions and lifestyle.&lt;/p&gt;
	&lt;p class="btn"&gt;&lt;a href="#"&gt;See more videos&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</pre>
</div>
<p>In the second column, the list of events has a layout that lends itself well to being rendered as a definition list, with the date and event description being relative to each other. The date can be set as the definition title, and the definition description as the content, which will help us target these tags to style up the fancy layout we’ve got going on. With the dates being laid out vertically at different type sizes, adding a span around the month will help provide that extra hook needed for the CSS styling.</p>
<div>
<pre>&lt;div class="column"&gt;
	&lt;h2 class="events"&gt;Upcoming Events&lt;/h2&gt;
	&lt;dl&gt;
		&lt;dt&gt;5 &lt;span&gt;Feb&lt;/span&gt;&lt;/dt&gt;
		&lt;dd&gt;
			&lt;h4&gt;5th Annual BigAir Jam&lt;/h4&gt;
			&lt;p&gt;Elite riders compete for the title of 2010 BigAir champion in the 5th annual running of the event in Sallback, Austria. Last year’s winner Nate Bailey is returning to defend his crown against some of the most elite names from Europe and the USA.&lt;/p&gt;
		&lt;/dd&gt;

		&lt;dt&gt;3 &lt;span&gt;Mar&lt;/span&gt;&lt;/dt&gt;
		&lt;dd&gt;
			&lt;h4&gt;Salomon Shred Round 1&lt;/h4&gt;
			&lt;p&gt;Elite riders compete for the title of 2010 BigAir champion in the 5th annual running of the event in Sallback, Austria. Last year’s winner Nate Bailey is returning to defend his crown against some of the most elite names from Europe and the USA.&lt;/p&gt;
		&lt;/dd&gt;
	&lt;/dl&gt;
	&lt;p class="btn"&gt;&lt;a href="#"&gt;See more events&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</pre>
</div>
<p>The last portion of content is the list of team members. Again, this list of objects is tailored nicely to be written as an unordered list element. Within each list element is an anchor link that will head off to the relevant page. Each anchor also has a class to help identify each team member when styling them up.</p>
<div>
<pre>&lt;h2 class="team"&gt;Meet the Team&lt;/h2&gt;

&lt;ul id="team"&gt;
	&lt;li&gt;&lt;a href="#" class="joe"&gt;Joe&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#" class="charlie"&gt;Charlie&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#" class="lars"&gt;Lars&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#" class="marco"&gt;Marco&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</div>
<h4>The footer</h4>
<p>The HTML is then closed out with the footer, containing a simple back-to-top link, and the body and HTML tags closed to finish off the document. A quick validation ensures there’s no errors, meaning it’s time to move onto some CSS styling.</p>
<div>
<pre>	&lt;div id="footer"&gt;
		&lt;p&gt;&lt;a href="#header" class="back-top"&gt;Back to top&lt;/a&gt;&lt;/p&gt;
	&lt;/div&gt;

&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
<h3>Styling the CSS</h3>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/body.jpg" alt="Body styling complete" /></p>
<p>The first line of CSS that’s written is to quickly reset any browser specific styling. Ensuring that we’re starting from a clean slate when it comes to margins, padding and borders. Next, the sans-serif font-family is set on the body tag, to render the Helvetica font throughout the design. A line-height of 24px will help us stick to our 24px baseline grid from the design, and will help fix any differences between browsers.</p>
<p>The main background of the site is then added. First the flat blue colour is specified, then the large textured background. This is positioned at the top center, and told not to repeat. Unlike inline images, background images don’t create scrollbars if they are larger than the content window, so despite our graphic being a huge 2200 pixels wide, a portion of the edges will be hidden according to how large the viewer’s monitor is.</p>
<div>
<pre>body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, blockquote {
	margin: 0; padding: 0; border: 0;
}

body {
	font-family: Helvetica, Arial, Sans-Serif; line-height: 24px;
	background: #b9d2f8 url(images/body-bg.jpg) center top no-repeat;
}
</pre>
</div>
<h4>The header</h4>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/head.jpg" alt="Styling the header section" /></p>
<p>Next up for styling is the main container div, which is simply given a 980px width and set to appear centrally. This is followed by the header and its sub-elements. The header div is given some padding to create the spacing at the top and sides according to the PSD concept, and is given an overflow:hidden property to clear itself and correctly calculate its height after the floated navigation elements.</p>
<p>The header one tag is given specific dimensions in order to properly display the logo as a background image, and a negative text-indent shifts the standard header text out of the way off-screen. The navigation is then floated alongside it, with a little margin to help align the elements. Each anchor inside the list items is styled to give the appropriate appearance according to the PSD concept, which includes setting the font-size and gaps between each element. They are then finished off with the addition of the transparent brush stroke graphic as a background image for links that have the active class, or are being hovered by the mouse.</p>
<div>
<pre>#container {
	width: 980px; margin: 0 auto;
}

#header {
	padding: 48px 16px 0 16px; overflow: hidden;
}
	#header h1 a {
		display: block; width: 221px; height: 107px; float: left;
		background: url(images/logo.jpg); text-indent: -9999px;
	}

	#header ul#nav {
		width: 720px; float: right; margin: 42px 0 0 0;
	}
		#header ul#nav li {
			float: left; list-style: none;
		}
			#header ul#nav li a {
				display: block; width: 155px; height: 34px; margin: 0 0 0 25px; padding: 12px 0 0 0;
				font-size: 24px; text-transform: lowercase; color: #fff; text-decoration: none; text-align: center;
				text-shadow: 0 3px 3px #333;
			}
				#header ul#nav li a:hover, #header ul#nav li a.active {
					background: url(images/active-nav.png);
				}
</pre>
</div>
<h4>General content styling</h4>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/content.jpg" alt="Styling the content background" /></p>
<p>The main central content area can then be styled to mimic the original PSD concept. First it’s given a specific width, with padding to push the content away from the edges. It’s set to overflow:hidden because it will contain some floated elements, and is given a transparent-white background PNG to create the translucent effect. Other options to create the white transparency could have been the opacity property, or the CSS3 RGBa property, but a good old PNG-24 graphic is the most cross-browser friendly, with just IE6 requiring extra work to enable the alpha transparency.</p>
<p>To finish off the content area, a small radius is added to the corners using the border-radius property. Because this isn’t fully supported yet, browser specific code can tell individual browsers to add the novelty effect.</p>
<div>
<pre>#content {
	width: 938px; padding: 16px 16px 60px 16px; overflow: hidden;
	background: url(images/white-trans.png);
	border-radius: 3px;
	-moz-border-radius: 3px;
	-webkit-border-radius: 3px;
}
</pre>
</div>
<h4>Styling the feature section</h4>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/features.jpg" alt="Styling the features section" /></p>
<p>The large features section in the design currently holds three slides, but the aim is to only display one at a time. When Javascript is added, these can be tweaked to transitionally fade between each one, but we also need the section to work without Javascript being enabled. To do this, the features section is given the specific dimensions of one slide. The overflow:scroll property will then add scrollbars to allow the user to manually navigation between slides. The UL is given a width of 2820px (3x the width of the slides), and they’re floated side by side. Without limiting the features container to a specific size, the slides would simply fill up the whole page, which ruins the usability of the site. This way, the user can experience the features slideshow, albeit in a much more low-tech way.</p>
<div>
<pre>#content #features {
	width: 940px; height: 457px; margin: 0 0 48px 0;
	overflow: scroll; /* Changed to hidden if javascript enabled */
}
	#content #features ul {
		width: 2820px;
	}

	#content #features ul li {
		float: left;
	}
</pre>
</div>
<h4>Styling the columns and their content</h4>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/columns.jpg" alt="Styling the columns content" /></p>
<p>Remember those two columns we wrote out in the HTML? They need floating side by side, so a width is calculated that will fit inside the content div, and the float:left property added. Inside these columns the video and upcoming events sections are styled. The video div simply has an image background to style up the embedded video, and some padding quickly aligns everything up. The definition list for the events section requires some extra CSS to manipulate the basic definition list element into the fancy layout we have planned. The date of each event is contained within the definition title, so that can be floated to the side and set to a large font-size. The extra span we added then comes in handy to render the  month text at a smaller font-size, and as a block element so that it drops down below the number.</p>
<p>The definition description and its header h4 tags can then be given the appropriate typographic treatment once the DD is floated alongside the DT. With all styling complete it matches the original concept perfectly.</p>
<div>
<pre>#content .column {
	width: 409px; float: left; padding: 0 30px 0 30px; margin: 0 0 24px 0;
}
	#content .column .video {
		width: 387px; height: 222px; padding: 13px 0 0 17px; margin: 0 0 24px 0;
		background: url(images/video-bg.jpg) no-repeat;
	}

	#content .column dl dt {
		width: 55px; float: left; padding: 10px 0 0 0;  overflow: auto;
		color: #fff; font-size: 64px; line-height: 34px;
	}
		#content .column dl dt span {
			font-size: 16px; text-transform: uppercase; display: block;;
		}
		#content .column dl dd {
			float: left; width: 354px;
		}

		#content .column dl h4 {
			font-size: 32px; font-weight: normal; color: #fff; margin: 0 0 5px 0;
		}
</pre>
</div>
<h4>Styling the team list</h4>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/team.jpg" alt="Styling the team section" /></p>
<p>The last part of the content styling is to flesh out the list of team members. Earlier each team member photo was exported, so these can now be set to each individual anchor tag. Each list item is set to float left, and is given the appropriate margin to space them out across the page. Anchor elements are by default inline elements, so to allow a specific width and height to be set, they need to be converted to display:block. Each individual team member can then be targeted through the class names on each anchor, with each photo graphic and image dimensions being added as a background.</p>
<div>
<pre>#content ul#team {
	list-style: none; overflow: hidden;
}
	#content ul#team li {
		float: left; margin: 0 0 0 27px;
	}
		#content ul#team li a {
			display: block; text-indent: -9999px;
		}
			#content ul#team li a.joe {
				width: 199px; height: 229px;
				background: url(images/joe.jpg);
			}
			#content ul#team li a.charlie {
				width: 199px; height: 229px;
				background: url(images/charlie.jpg);
			}
			#content ul#team li a.lars {
				width: 205px; height: 233px;
				background: url(images/lars.jpg);
			}
			#content ul#team li a.marco {
				width: 198px; height: 229px;
				background: url(images/marco.jpg);
			}
</pre>
</div>
<h4>Styling the footer</h4>
<p><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/footer.jpg" alt="Styling the footer" /></p>
<p>The footer area can be quickly finished up by adding the subtle texture background, and the back-to-top link floated over to the right, styled up and positioned into place.</p>
<div>
<pre>#footer {
	min-height: 159px; overflow: hidden;
	background: url(images/footer-bg.jpg) center 0 no-repeat;
}
	#footer p a.back-top {
		float: right; margin: 14px 24px 0 0;
		font-size: 12px; text-decoration: none; color: #4d74bb;
	}
		#footer p a.back-top:hover {
			color: #234c97;
		}
</pre>
</div>
<h3>Adding the Javascript</h3>
<p>Let’s not forget the extra Javascript effects we had planned for that features section. With the help of some <a href="http://jquery.com/">jQuery</a>, and the super cool <a href="http://malsup.com/jquery/cycle/">Cycle plugin</a>, we can easily transform that basic features list into a fully working slideshow.</p>
<div>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="js/scripts.js" type="text/javascript"&gt;&lt;/script&gt;
</pre>
</div>
<p>First, the jQuery library and our own scripts file is referenced in the HTML. The cycle plugin is included in the scripts.js, then some of our own Javascript can put it all into practice. First the overflow:scroll on the features list needs changing to hidden to remove those ugly scrollbars, then the cycle plugin is initiated on the features list. By default the plugin will place a simple fading transition between each element, but there’s plenty more options that could be configured.</p>
<div>
<pre>$(document).ready(function() {

/* Change the overflow:scroll to overflow hidden on the Features list */

	$('#features').css('overflow','hidden');

/* Initiate the cycle on the Features list */
	$('#features ul').cycle();
});
</pre>
</div>
<h3>The final concept</h3>
<p><a href="http://line25.com/wp-content/uploads/2010/snowboard-design-code/demo/index.html"><img src="http://line25.com/wp-content/uploads/2010/snowboard-design-code/final.jpg" alt="View the final demo" /></a></p>
<p>So here we have the complete mockup in live HTML and CSS format. Our HTML is clean and valid, and the CSS renders everything how we wanted according to the original PSD concept.</p>
<p><a href="http://line25.com/wp-content/uploads/2010/snowboard-design-code/demo/index.html">View the demo</a></p>

	Tags: <a href="http://xguiden.dk/tag/ajax/" title="AJAX" rel="tag">AJAX</a>, <a href="http://xguiden.dk/tag/avi/" title="avi" rel="tag">avi</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/fix/" title="fix" rel="tag">fix</a>, <a href="http://xguiden.dk/tag/flash/" title="Flash" rel="tag">Flash</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/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/lp/" title="LP" rel="tag">LP</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/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/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/server/" title="Server" rel="tag">Server</a>, <a href="http://xguiden.dk/tag/standard/" title="standard" rel="tag">standard</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/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/valid/" title="valid" rel="tag">valid</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/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/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/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/15/how-to-code-up-a-web-design-from-psd-to-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
