<?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>Stiern.com &#187; Tutorials</title> <atom:link href="http://stiern.com/category/tutorials/feed" rel="self" type="application/rss+xml" /><link>http://stiern.com</link> <description>Web design, graphic design, Photoshop, CSS, etc</description> <lastBuildDate>Sat, 28 Aug 2010 15:07:45 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Create a Cool Messy List with CSS3 and nth-child</title><link>http://stiern.com/tutorials/create-a-cool-messy-list-with-css3-and-nth-child</link> <comments>http://stiern.com/tutorials/create-a-cool-messy-list-with-css3-and-nth-child#comments</comments> <pubDate>Thu, 15 Apr 2010 07:00:34 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[nth-child]]></category><guid
isPermaLink="false">http://stiern.com/?p=920</guid> <description><![CDATA[While working on a design recently, I stumbled upon Chris Coyier&#8217;s article How nth-child Works. Chris shows us the basics of the nth-child pseudo-selector in CSS. It can be used for so many things, but in this short tutorial I&#8217;m going to show you how to create a cool messy list. First, check out the [...]]]></description> <content:encoded><![CDATA[<p>While working on a design recently, I stumbled upon Chris Coyier&#8217;s article <em><a
title="How nth-child Works | CSS-Tricks" href="http://css-tricks.com/how-nth-child-works/">How nth-child Works</a></em>. Chris shows us the basics of the nth-child pseudo-selector in CSS. It can be used for so many things, but in this short tutorial I&#8217;m going to show you how to create a cool messy list.<br
/> <span
id="more-920"></span><br
/> First, check out the demo to see what we&#8217;re creating in <a
href="http://dl.dropbox.com/u/32709/stiern/messylist/index.html" title="Demo">the demo</a>.</p><p>We&#8217;re going to start with an HTML5 document (why not?), and include a stylesheet, as shown below:</p><div
class="wp_syntax"><div
class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Messy List<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Messy List<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;header&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Messy List<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>header&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;section&gt;</span>
&nbsp;
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Lorem ipsum dolor sit amet<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Duis aute irure dolor in reprehenderit.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Excepteur sint occaecat cupidatat.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Ut enim ad minim veniam.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>section&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;footer&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Copyright <span style="color: #ddbb00;">&amp;copy;</span> 2010<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>footer&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div><p>That&#8217;s a pretty simple HTML document—and of course the most important part is the list. Next, here&#8217;s the stylesheet (with an HTML5 CSS reset in it as well). You can get the background from <a
href="http://seamlesstextures.net/textures/grid%20paper" title="SeamlessTextures">SeamlessTextures</a>. I&#8217;ve modified it in color and size, so you can also just get <a
href="http://dl.dropbox.com/u/32709/stiern/messylist/background.png" title="Modified background">my version</a>.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* HTML 5 Reset */</span>
html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> span<span style="color: #00AA00;">,</span> object<span style="color: #00AA00;">,</span> iframe<span style="color: #00AA00;">,</span> h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> blockquote<span style="color: #00AA00;">,</span> pre<span style="color: #00AA00;">,</span> a<span style="color: #00AA00;">,</span> abbr<span style="color: #00AA00;">,</span> address<span style="color: #00AA00;">,</span> cite<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span> del<span style="color: #00AA00;">,</span> dfn<span style="color: #00AA00;">,</span> em<span style="color: #00AA00;">,</span> img<span style="color: #00AA00;">,</span> ins<span style="color: #00AA00;">,</span> kbd<span style="color: #00AA00;">,</span> q<span style="color: #00AA00;">,</span> samp<span style="color: #00AA00;">,</span> small<span style="color: #00AA00;">,</span>  strong<span style="color: #00AA00;">,</span> sub<span style="color: #00AA00;">,</span> sup<span style="color: #00AA00;">,</span> var<span style="color: #00AA00;">,</span> b<span style="color: #00AA00;">,</span> i<span style="color: #00AA00;">,</span> dl<span style="color: #00AA00;">,</span> dt<span style="color: #00AA00;">,</span> dd<span style="color: #00AA00;">,</span> ol<span style="color: #00AA00;">,</span> ul<span style="color: #00AA00;">,</span> li<span style="color: #00AA00;">,</span> fieldset<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> legend<span style="color: #00AA00;">,</span> table<span style="color: #00AA00;">,</span> caption<span style="color: #00AA00;">,</span> tbody<span style="color: #00AA00;">,</span> tfoot<span style="color: #00AA00;">,</span> thead<span style="color: #00AA00;">,</span> tr<span style="color: #00AA00;">,</span> th<span style="color: #00AA00;">,</span> td <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">baseline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
section<span style="color: #00AA00;">,</span> article<span style="color: #00AA00;">,</span> aside<span style="color: #00AA00;">,</span> header<span style="color: #00AA00;">,</span> footer<span style="color: #00AA00;">,</span> nav<span style="color: #00AA00;">,</span> dialog<span style="color: #00AA00;">,</span> figure <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">background.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span> <span style="color: #993333;">auto</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Georgia<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>odd<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>odd<span style="color: #00AA00;">&#41;</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>even<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>even<span style="color: #00AA00;">&#41;</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>3n<span style="color: #00AA00;">+</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-moz-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>3n<span style="color: #00AA00;">+</span><span style="color: #cc66cc;">2</span><span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0.5deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-moz-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0.5deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0.5deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>3n<span style="color: #00AA00;">+</span><span style="color: #cc66cc;">3</span><span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0.2deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-moz-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0.2deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0.2deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>I guess there&#8217;s not much new for you here, but let&#8217;s break it down a bit anyway. First, we define the width of our body to be 600px. Also, we include the aforementioned background, specify font and color, and add a top margin. Next, we define the size of our H1. And now comes the fun part.</p><p>We remove the dots from our list with <code>list-style: none;</code>, and add a little padding to our list elements. We&#8217;ll look at the nth-child selectors in bits. Check out the first one:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>odd<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>odd<span style="color: #00AA00;">&#41;</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>even<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.3</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>even<span style="color: #00AA00;">&#41;</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">50</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div><p>We choose every second <code>li</code> element, and add a background to it. In this case, we choose a dark gray, and set the opacity to 0.1 (RGBA is new in CSS3), so we can see the background through the <code>li</code> elements. We do exactly the same for our even elements, with the opacity set to 0.3. This is just basic zebra striping. You can add several selectors to an element, so we also add a hover background color a little darker than the original element.</p><p>Next, we target <code>3n+1</code>—that is, every third element, starting with the first.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">ul li<span style="color: #3333ff;">:nth-</span>child<span style="color: #00AA00;">&#40;</span>3n<span style="color: #00AA00;">+</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span>
	-webkit-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-moz-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div><p>We rotate the list element by -0.6 degrees. We do the same thing for both <code>3n+2</code> (every third element, starting with the second) and <code>3n+3</code> (you get the idea). By rotating every third element, and doing zebra striping with every second element, the list seems sort of random, which, I think, is a really cool effect.</p><p>If you use Safari, Firefox or Chrome, this is what you should have:<br
/> <a
class="lightbox postimg"  title ="Mess List" href="http://stiern.com/site/wp-content/everything/messylist.png"><img
src="http://stiern.com/site/wp-content/everything/messylist.png" alt="" title="Mess List" width="540" height="267" class="alignnone size-full wp-image-932" /></a></p><p><b>UPDATE:</b> You can target Opera with the following (thanks to <a
href="http://stiern.com/tutorials/create-a-cool-messy-list-with-css3-and-nth-child/comment-page-1#comment-5821">ToMzorz</a>):</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">-o-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-0.6deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div><p>You can also check out <a
href="http://dl.dropbox.com/u/32709/stiern/messylist/index.html" title="Demo">the demo</a> again, or download the <a
href="http://dl.dropbox.com/u/32709/stiern/messylist/messylist.zip" title="Source code">source code</a>.</p><p>Thanks for reading.</p><p>Related posts:<ol><li><a
href='http://stiern.com/tutorials/enhancing-your-site-with-webkit' rel='bookmark' title='Permanent Link: Enhancing Your Site with WebKit'>Enhancing Your Site with WebKit</a></li><li><a
href='http://stiern.com/articles/css3-is-not-freaking-html5' rel='bookmark' title='Permanent Link: CSS3 is Not Freaking HTML5'>CSS3 is Not Freaking HTML5</a></li><li><a
href='http://stiern.com/articles/5-cool-ways-to-add-graphs-to-your-website' rel='bookmark' title='Permanent Link: 5 Cool Ways to Add Graphs to Your Website'>5 Cool Ways to Add Graphs to Your Website</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/create-a-cool-messy-list-with-css3-and-nth-child/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>How to Use Directions with Google Maps API V3</title><link>http://stiern.com/tutorials/how-to-use-directions-with-google-maps-api-v3</link> <comments>http://stiern.com/tutorials/how-to-use-directions-with-google-maps-api-v3#comments</comments> <pubDate>Mon, 09 Nov 2009 08:20:59 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Google Maps]]></category> <category><![CDATA[Web Design]]></category><guid
isPermaLink="false">http://stiern.com/?p=801</guid> <description><![CDATA[Google Maps are more fun when you can get directions. And now you can! The recent release of the Google Maps API adds two new classes in order to enable directions. In this article I will show you how to add an input field in an infobox and use that to render a route. But [...]]]></description> <content:encoded><![CDATA[<p>Google Maps are more fun when you can get directions. And now you can! The recent release of the Google Maps API adds two new classes in order to enable directions. In this article I will show you how to add an input field in an infobox and use that to render a route.</p><p><span
id="more-801"></span></p><p>But before that, here&#8217;s how it looks when it is done:</p><div
class="iframe-wrapper"> <iframe
src="http://dl.getdropbox.com/u/32709/googlemaps_dir/index.html" frameborder="0" style="height:300px;width:500px;">Please upgrade your browser</iframe></div><p>Because of the size at the page here the infobox gets a scroll bar, but just ensure to make your map large enough, then it will not happen.</p><h3>Overview</h3><ul><li><a
href="#whatsnew">What&#8217;s New?</a></li><li><a
href="#corrections">Corrections</code></li><li><a
href="#directions">The Directions</a></li><li><a
href="#calcRoute">Calculating the Route</a></li><li><a
href="#conclusion">Conclusion</code></li></ul><h3><a
id="whatsnew">What's New?</a></h3><p>Since my <a
href="http://stiern.com/tutorials/adding-custom-google-maps-to-your-website" title="Adding Custom Google Maps to Your Website">last article</a> a couple of new features have been added to the API, as you can also read about in the <a
href="http://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog" title="Google Maps API V3 changelog">changelog</a>. The most important, in my opinion, is of course the support of directions, and that's the only function I will discuss here. Worthy to note, though &mdash; you do not have to use an API code anymore.</p><p>The support for directions is possible via two new classes, <code>DirectionsRenderer</code> and <code>DirectionsService</code>. <code>DirectionsRenderer</code>&hellip; Well&hellip; Renders the directions, and <code>DirectionsService</code> computes the actual directions. But the big question is &mdash; how do we use them?</p><h3><a
id="corrections">Corrections</a></h3><p>Before we rush into the new code, we should make some corrections in our excisting code. If you haven't read my article <a
href="http://stiern.com/tutorials/adding-custom-google-maps-to-your-website" title="Adding Custom Google Maps to Your Website">Adding Custom Google Maps to Your Website</a>, do yourself a favor and do so before continuing on this one.</p><p><br
/> &nbsp;</p><p>Next, look in your code where you define your markers and ensure that your values follow these rules:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> companyImage <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">MarkerImage</span><span style="color: #009900;">&#40;</span>’images<span style="color: #339933;">/</span>logo.<span style="color: #660066;">png</span>’<span style="color: #339933;">,</span>
<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Size</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// (width, height)</span>
 <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// (width/2, height) );</span>
<span style="color: #003366; font-weight: bold;">var</span> companyShadow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">MarkerImage</span><span style="color: #009900;">&#40;</span>’images<span style="color: #339933;">/</span>logo_shadow.<span style="color: #660066;">png</span>’<span style="color: #339933;">,</span>
 <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Size</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">130</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// (width, height) </span>
<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">65</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// (width/2, height) );</span></pre></td></tr></table></div><p>Dividing the image's width by 2 ensures that it's the bottom center point of the image that'll be used for the marker. Thanks to <a
href="http://stiern.com/tutorials/adding-custom-google-maps-to-your-website/comment-page-2#comment-2663" title="JM">JM</a> for this solution.</p><h3><a
id="directions">The Directions</a></h3><p>So, first we have to call the <code>DirectionsService</code> constructor. Before your <code>initialize()</code>, create a new variable:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> directionsService <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">DirectionsService</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Next, we have to create the renderer. Right before the variable you just created, define a new variable <code>directionDisplay</code>. This variable is going to contain the renderer.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> directionDisplay<span style="color: #339933;">;</span></pre></td></tr></table></div><p>In your <code>initialize()</code> function, right after the <code>latLng</code> variable, set the <code>directionDisplay</code> variable to this:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">directionsDisplay <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">DirectionsRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Further down in your code, find the <code>map</code> variable (right after the <code>settings</code> variable. Write this:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">directionsDisplay.<span style="color: #660066;">setMap</span><span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>This renders the marker on the specified map, which in this case is <code>map</code>. Next, let's define what we want to write in our infobox by expanding the <code>contentString</code> variable:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #003366; font-weight: bold;">var</span> contentString <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div id=&quot;content&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;div id=&quot;siteNotice&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;h1 id=&quot;firstHeading&quot; class=&quot;firstHeading&quot;&gt;Høgenhaug&lt;/h1&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;div id=&quot;bodyContent&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;p&gt;Find your way here from:&lt;/p&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;form action=&quot;index.html&quot; onsubmit=&quot;calcRoute();return false;&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;input type=&quot;text&quot; id=&quot;start&quot; value=&quot;prinsensgade 5, 9000&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;input type=&quot;submit&quot; value=&quot;Find directions&quot;&gt;&lt;/form&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Let's look a bit into the <code>form</code> used to ask the user for an address:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #3366CC;">'&lt;form action=&quot;index.html&quot; onsubmit=&quot;calcRoute();return false;&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;input type=&quot;text&quot; id=&quot;start&quot; value=&quot;prinsensgade 5, 9000&quot;&gt;'</span><span style="color: #339933;">+</span>
	<span style="color: #3366CC;">'&lt;input type=&quot;submit&quot; value=&quot;Find directions&quot;&gt;&lt;/form&gt;'</span><span style="color: #339933;">+</span></pre></td></tr></table></div><p>First, we write "index.html" in our <code>action</code> attribute. This path should be to the file where your map is placed. In <code>onsubmit</code> we call the function <code>calcRoute()</code> (which we will define later), and next we write <code>return false</code> to prevent the site from reloading when the user submits the form. The next two lines should be pretty self-explainable. If you want the user to be able to enter both addresses, you can just add an extra input field called <code>end</code>. The value of the <code>start</code> field can be empty or you can write a pre-defined address.</p><h3><a
id="calcRoute">Calculating the Route</a></h3><p>At the very end of the <code>initialize()</code> function, write the following:</p><pre lang="javascript" line="1>
function calcRoute() {
	var start = document.getElementById("start").value;
	var end = "57.0442, 9.9116";
	var request = {
		origin:start,
		destination:end,
		travelMode: google.maps.DirectionsTravelMode.DRIVING
	};
</pre><p>In the <code>form</code> we called the function <code>calcRoute()</code>. That's the one we are defining here. The first thing to do is define the two variables <code>start</code> and <code>end</code>. If you inserted an extra input field before write <code>document.getElementById("end").value;</code> in <code>end</code> instead of the coordinates.</p><p>Next, define the variable <code>request</code>. The attributes of this one are fairly logical, but let's explain them just in case. We define the <code>origin</code> of the route to our variable <code>start</code>, and the destination to <code>end</code>. Also, we define a travelmode &mdash;. This can be either <code>DRIVING</code> or <code>WALKING</code>.</p><p>Lastly, insert this code:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">directionsService.<span style="color: #660066;">route</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #339933;">,</span> <span style="color: #000066;">status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">status</span> <span style="color: #339933;">==</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">DirectionsStatus</span>.<span style="color: #660066;">OK</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		directionsDisplay.<span style="color: #660066;">setDirections</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>This issues the actual search request, and completes the <code>initialize()</code> function.</p><h3><a
id="conclusion">Conclusion</a></h3><p>With very little effort you can show your visitor how to get to your address directly from your website, instead of sending them to Google Maps or some other place. I hope you enjoyed the tutorial &mdash; please let me know if you have questions or suggestions. You are of course free to download the <a
href="http://dl.dropbox.com/u/32709/googlemaps_dir/googlemaps_directions.zip" title="The source files">source files</a>.</p><p>While you are here, why don't you <a
href="http://twitter.com/pshoeg" title="Follow me on Twitter">follow me on Twitter</a> or subscribe to the <a
href="http://feeds.feedburner.com/stiern" title="Subscribe to the RSS feed">RSS feed</a>?</p><p>Related posts:<ol><li><a
href='http://stiern.com/tutorials/adding-custom-google-maps-to-your-website' rel='bookmark' title='Permanent Link: Adding Custom Google Maps to Your Website'>Adding Custom Google Maps to Your Website</a></li><li><a
href='http://stiern.com/tutorials/enhancing-your-site-with-webkit' rel='bookmark' title='Permanent Link: Enhancing Your Site with WebKit'>Enhancing Your Site with WebKit</a></li><li><a
href='http://stiern.com/tutorials/no-more-invalid-rss' rel='bookmark' title='Permanent Link: No More Invalid RSS'>No More Invalid RSS</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/how-to-use-directions-with-google-maps-api-v3/feed</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>Adding Custom Google Maps to Your Website</title><link>http://stiern.com/tutorials/adding-custom-google-maps-to-your-website</link> <comments>http://stiern.com/tutorials/adding-custom-google-maps-to-your-website#comments</comments> <pubDate>Mon, 12 Oct 2009 22:56:47 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Google Maps]]></category> <category><![CDATA[Web Design]]></category><guid
isPermaLink="false">http://stiern.com/?p=626</guid> <description><![CDATA[Maps are often placed on a company website to help customers find their way there. For that, Google Maps is excellent. But wouldn&#8217;t it be nice to add your company logo, parking lots, train stations, etc. to the map, to help the customer even more? It is very simple, and in this article I am [...]]]></description> <content:encoded><![CDATA[<p>Maps are often placed on a company website to help customers find their way there. For that, Google Maps is excellent. But wouldn&#8217;t it be nice to add your company logo, parking lots, train stations, etc. to the map, to help the customer even more? It is very simple, and in this article I am going to show you how.<br
/> <span
id="more-626"></span></p><p>Before we start, check out what we are going to create:</p><div
class="iframe-wrapper"> <iframe
src="http://dl.getdropbox.com/u/32709/googlemaps/index.html" frameborder="0" style="height:300px;width:500px;">Please upgrade your browser</iframe></div><p>Now, here is an overview:</p><h3>Overview</h3><ul><li><a
href="#google_api">Google Maps API</a></li><li><a
href="#coordinates">Getting the Coordinates</a></li><li><a
href="#adding_the_map">Adding the Map to Your Website</a></li><li><a
href="#adding_markers">Adding Markers</a></li><li><a
href="#custom_markers">Customizing the Markers</a></li><li><a
href="#infobox">Adding Infoboxes</a></li><li><a
href="#download">Download</a></li></ul><h3><a
id="google_api">Google Maps API</a></h3><p>The Google Maps API allows you to embed maps directly into your website. All it takes is a little JavaScript, and for beautifying&#8212;a little CSS. <a
title="Google Maps API V3" href="http://code.google.com/apis/maps/documentation/v3/">Version 3</a> of the Google Maps API has just been released, and of course, that is what we will be using here. You can read the entire documentation over at <a
title="Google Labs" href="http://code.google.com/intl/en-EN/apis/maps/documentation/v3/">Google Labs</a>, and while you are there, be sure to get an <a
title="Google Maps API key" href="http://code.google.com/intl/en-EN/apis/maps/signup.html">API key</a>.</p><h3><a
id="coordinates">Getting the Coordinates</a></h3><p>As I do not expect you to know the precise coordinates of your location, I will explain a very quick way Google has provided to do this. When you know the exact address, you can put it in an URL of this form:</p><div
class="wp_syntax"><div
class="code"><pre class="javascript" style="font-family:monospace;">http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//maps.google.com/maps/geo?q=1+Infinite Liip,+Cupertino,+CA+95014,+USA&amp;output=csv&amp;oe=utf8&amp;sensor=false&amp;key=your_google_maps_api_key</span></pre></div></div><p>When you enter this in your address bar, you will see this:</p><div
id="attachment_653" class="wp-caption alignnone" style="width: 255px"><a
class="lightbox"  title ="The coordinates of Apple's head quarter in Cupertino" href="http://stiern.com/site/wp-content/everything/apple_coordinates.png"><img
src="http://stiern.com/site/wp-content/everything/apple_coordinates.png" alt="The coordinates of Apple&#039;s head quarter in Cupertino" title="The coordinates of Apple&#039;s head quarter in Cupertino" width="245" height="28" class="size-full wp-image-653" /></a><p
class="wp-caption-text">The coordinates of Apple's head quarter in Cupertino</p></div><p>The first number is the <a
href="http://code.google.com/intl/da-DK/apis/maps/documentation/geocoding/index.html#StatusCodes" title="Status Codes">status code</a>, and 200 means that everything is okay. The second number shows how <a
href="http://code.google.com/intl/da-DK/apis/maps/documentation/geocoding/index.html#GeocodingAccuracy" title="Accuracy">accurate</a> the address is&#8212;in this case the number is 8, which is good. The last two numbers are latitudes and longitudes, which are the numbers we need.</p><h3><a
id="adding_the_map">Adding the Map to Your Website</a></h3><p>There&#8217;s no need to hesitate – let&#8217;s add that map to your website! Open your favorite HTML editor and create a standard HTML file with UTF-8 encoding. First of all, we have to create the viewport and tell our HTML file to get the JavaScript file from Google Code. Add these lines between <code>&lt;head&gt; and &lt;/head&gt;</code>:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;initial-scale=1.0, user-scalable=no&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.google.com/maps/api/js?sensor=false&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div><p>After the URL, you will notice <code>sensor=false</code>. As we do not use any sensor, such as a GPS, to locate the location, this is set to false.</p><p>Just below what we have just inserted, write the following:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #003366; font-weight: bold;">function</span> initialize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> latlng <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">LatLng</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">57.0442</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9.9116</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> settings <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
			zoom<span style="color: #339933;">:</span> <span style="color: #CC0000;">15</span><span style="color: #339933;">,</span>
			center<span style="color: #339933;">:</span> latlng<span style="color: #339933;">,</span>
			mapTypeControl<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			mapTypeControlOptions<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>style<span style="color: #339933;">:</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">MapTypeControlStyle</span>.<span style="color: #660066;">DROPDOWN_MENU</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			navigationControl<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			navigationControlOptions<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>style<span style="color: #339933;">:</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">NavigationControlStyle</span>.<span style="color: #660066;">SMALL</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			mapTypeId<span style="color: #339933;">:</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">MapTypeId</span>.<span style="color: #660066;">ROADMAP</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Let&#8217;s split this up to ensure that we understand it fully. In line 2 we create the function <code>initialize()</code>. Inside this function we are going to define the basic settings of the map. In line 3 we create a new variable, <code>latlng</code>. <code>latlng</code> stands for latitudes and longitudes. The variable contains the coordinates we&#8217;re going to use as the center of our map.<br
/> After that, we create the variable <code>settings</code>. You have a lot of options here.</p><p><code>zoom</code> specifies&#8212;you guessed it&#8212;how far the map will be zoomed in. Play around with the number to get it to fit your location.</p><p><code>center</code> specifies our center. By writing <code>latlng</code>, we refer to the variable we created earlier, and the coordinate inside that will be used.</p><p>The last code changes the layout of the map to a bit more minimalistic look in my opinion. The controls in the upper right corner (Map, Satellite, Terrain) are changed to a drop down menu, and the scaling/navigation controls in the left size are changed to small controls.</p><p><code>mapTypeId: google.maps.MapTypeId.ROADMAP</code> defines that our map should be of the type <code>ROADMAP</code> – you can change this to either <code>SATELLITE</code>, <code>HYBRID</code> or <code>TERRAIN</code>.</p><p>Below the previous code, write this:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;map_canvas&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> settings<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>This code creates the variable <code>map</code>, and defines that the map should use the settings we just created.</p><p>Write</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="html4strict" style="font-family:monospace;">}
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div><p> to end the function, and move to <code>&lt;body&gt;</code>, and write this:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;initialize()&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map_canvas&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:800px; height:500px&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></pre></td></tr></table></div><p>By doing this we are telling our site to execute the <code>initialize()</code> function when the site is loaded, and insert a <code>&lt;div&gt;</code> with the size we want our map to be.</p><p>Try to view your site now. Cool, isn&#8217;t it?</p><h3><a
id="adding_markers">Adding Markers</a></h3><p>Now we have to add some markers. Let&#8217;s start by creating a standard marker&#8212;we&#8217;ll customize it in a moment.</p><p>Right below</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Map</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;map_canvas&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> settings<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p> insert the following code:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #003366; font-weight: bold;">var</span> companyPos <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">LatLng</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">57.0442</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9.9116</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> companyMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Marker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      position<span style="color: #339933;">:</span> companyPos<span style="color: #339933;">,</span>
      map<span style="color: #339933;">:</span> map<span style="color: #339933;">,</span>
      title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Some title&quot;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Try to update your page, and watch the magic. So, what have we done?</p><p>First, we create the variable <code>companyPos</code>, where we specify the position of the marker. Next, we create the marker itself using the variable <code>companyMarker</code>. You can add more settings than these, but we will get to that later. These settings are fairly logical, so I won&#8217;t go into more depth with them.</p><h3><a
id="custom_markers">Customizing the Markers</h3><p>Even though this could be enough to show your customer how to find you, we can still make it a lot nicer. Create an image in Photoshop with the size 100&#215;50 pixels, and create something similar to this:<br
/><div
id="attachment_660" class="wp-caption alignnone" style="width: 110px"><a
class="lightbox" title="Create your logo" href="http://stiern.com/site/wp-content/everything/logo.png"><img
class="size-full wp-image-660" title="Create your logo" src="http://stiern.com/site/wp-content/everything/logo.png" alt="Create your logo" width="100" height="50" /></a><p
class="wp-caption-text">Create your logo</p></div></p><p>Next, create a shadow for your image:</p><div
id="attachment_663" class="wp-caption alignnone" style="width: 140px"><a
class="lightbox" title="The logo shadow" href="http://stiern.com/site/wp-content/everything/logo_shadow.png"><img
class="size-full wp-image-663" title="The logo shadow" src="http://stiern.com/site/wp-content/everything/logo_shadow.png" alt="The logo shadow" width="130" height="50" /></a><p
class="wp-caption-text">The logo shadow</p></div><p>To add these images as a marker instead of the standard marker, change the marker code to this:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> companyLogo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">MarkerImage</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'images/logo.png'</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Size</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> companyShadow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">MarkerImage</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'images/logo_shadow.png'</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Size</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">130</span><span style="color: #339933;">,</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Point</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">65</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> companyPos <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">LatLng</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">57.0442</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9.9116</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> companyMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Marker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	position<span style="color: #339933;">:</span> companyPos<span style="color: #339933;">,</span>
	map<span style="color: #339933;">:</span> map<span style="color: #339933;">,</span>
	icon<span style="color: #339933;">:</span> companyLogo<span style="color: #339933;">,</span>
	shadow<span style="color: #339933;">:</span> companyShadow<span style="color: #339933;">,</span>
	title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Company Title&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>What we have done here is also really simple. The variable <code>companyImage</code> points to the name of the logo image. Then it defines the size of the image, the origin of the image, and the tip of the image (where the image will be attached to the coordinate). Next, we do the exact same thing for the shadow in the variable <code>companyShadow</code>. In our <code>companyMarker</code> variable we add <code>icon</code> and <code>shadow</code>, and that is basically it.</p><p>Now, if you refresh your site, you will se that the marker has changed into your own logo with an added shadow to it as well. To add more markers, you just follow the same method (remember to change the names of the variables).</p><p>If you have two markers very close to each other, you might want to add some z-index. The marker with the highest z-index, is the one on top:</p><div
id="attachment_674" class="wp-caption alignnone" style="width: 157px"><a
class="lightbox" title="Adding zIndex allows you to choose which marker should be on top" href="http://stiern.com/site/wp-content/everything/zindex.png"><img
class="size-full wp-image-674" title="Adding zIndex allows you to choose which marker should be on top" src="http://stiern.com/site/wp-content/everything/zindex.png" alt="Adding zIndex allows you to choose which marker should be on top" width="147" height="87" /></a><p
class="wp-caption-text">Adding zIndex allows you to choose which marker should be on top</p></div><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> companyMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">Marker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	position<span style="color: #339933;">:</span> companyPos<span style="color: #339933;">,</span>
	map<span style="color: #339933;">:</span> map<span style="color: #339933;">,</span>
	icon<span style="color: #339933;">:</span> companyImage<span style="color: #339933;">,</span>
	shadow<span style="color: #339933;">:</span> companyShadow<span style="color: #339933;">,</span>
	title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Høgenhaug&quot;</span><span style="color: #339933;">,</span>
	zIndex<span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><h3><a
id="infobox">Adding Infoboxes</a></h3><p>To add a description of your company when the visitor clicks on the logo we can add a infobox. With the Google Maps API it&#8217;s peace of cake.</p><div
id="attachment_677" class="wp-caption alignnone" style="width: 510px"><a
class="lightbox" title="Clicking your company logo will bring up an infobox" href="http://stiern.com/site/wp-content/everything/infobox.png"><img
class="size-full wp-image-677" title="Clicking your company logo will bring up an infobox" src="http://stiern.com/site/wp-content/everything/infobox.png" alt="Clicking your company logo will bring up an infobox" width="500" height="398" /></a><p
class="wp-caption-text">Clicking your company logo will bring up an infobox</p></div><p>Paste this code right after you define the <code>map</code> variable:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> contentString <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div id=&quot;content&quot;&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;div id=&quot;siteNotice&quot;&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;h1 id=&quot;firstHeading&quot; class=&quot;firstHeading&quot;&gt;Høgenhaug&lt;/h1&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;div id=&quot;bodyContent&quot;&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">+</span>
    <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> infowindow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">InfoWindow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    content<span style="color: #339933;">:</span> contentString
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>The code here is fairly straight-forward, and you are of course not limited to headlines and paragraphs – there is room for images as well. To make the infobox appear when your logo is clicked, simply add this code right before the last <code>}</code> in the <code>initialize()</code> function:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="javascript" style="font-family:monospace;">google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span>companyMarker<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  infowindow.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span>companyMarker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>To make the infobox just a little more pretty, add some styles in your stylesheet file:</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
</pre></td><td
class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Helvetica<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">10pt</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div><p>And there you have it. One piece of fine-looking Google Map to include on your company website, your travel blog, etc.</p><h3><a
id="download">Download</a></h3><p>If you&#8217;d like to download the sample files, you can get &#8216;em <a
href="http://dl.getdropbox.com/u/32709/googlemaps.zip" title="Download the example files">right here</a>. Be sure to leave a comment!</p><p>Related posts:<ol><li><a
href='http://stiern.com/tutorials/how-to-use-directions-with-google-maps-api-v3' rel='bookmark' title='Permanent Link: How to Use Directions with Google Maps API V3'>How to Use Directions with Google Maps API V3</a></li><li><a
href='http://stiern.com/articles/5-cool-ways-to-add-graphs-to-your-website' rel='bookmark' title='Permanent Link: 5 Cool Ways to Add Graphs to Your Website'>5 Cool Ways to Add Graphs to Your Website</a></li><li><a
href='http://stiern.com/tutorials/enhancing-your-site-with-webkit' rel='bookmark' title='Permanent Link: Enhancing Your Site with WebKit'>Enhancing Your Site with WebKit</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/adding-custom-google-maps-to-your-website/feed</wfw:commentRss> <slash:comments>165</slash:comments> </item> <item><title>Enhancing Your Site with WebKit</title><link>http://stiern.com/tutorials/enhancing-your-site-with-webkit</link> <comments>http://stiern.com/tutorials/enhancing-your-site-with-webkit#comments</comments> <pubDate>Fri, 03 Jul 2009 14:00:36 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Web Design]]></category> <category><![CDATA[WebKit]]></category><guid
isPermaLink="false">http://stiern.com/?p=366</guid> <description><![CDATA[WebKit is an open source browser engine. Apple uses WebKit in Safari, Mail, and other applications. Google&#8217;s Chrome browser, along with the S60 browser and the iPhone browser, is also built on WebKit. Some of the cool features of WebKit is transitions and transforms. With purely CSS you can create stunning animations. Your site will [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://webkit.org/">WebKit</a> is an open source browser engine. <a
title="Apple" href="http://apple.com/">Apple</a> uses WebKit in Safari, Mail, and other applications. <a
title="Google Chrome" href="http://www.google.com/chrome">Google&#8217;s Chrome</a> browser, along with the S60 browser and the iPhone browser, is also built on WebKit. Some of the cool features of WebKit is transitions and transforms. With purely CSS you can create stunning animations. Your site will still work in other browsers, but the users with WebKit browsers will just get a slightly better experience.</p><p><span
id="more-366"></span></p><p></p><p>Take for example Elliot Jay Stocks&#8217; new website, elliotjaystocks.com. It is in it self a very beautiful website, but if you open it in e.g. Safari 4, it&#8217;s even more beutiful. When you hover your mouse over the images, the border will slowly fade into a lighter color. In non-WebKit browsers, it&#8217;ll just be a very sudden transition. This done solely by CSS.</p><div
id="attachment_368" class="wp-caption alignnone" style="width: 510px"><a
href="http://elliotjaystocks.com"><img
class="size-full wp-image-368" title="elliotjaystocks" src="http://stiern.com/site/wp-content/everything/Billede-4.png" alt="Elliot Jay Stocks' new website" width="500" height="385" /></a><p
class="wp-caption-text">Elliot Jay Stocks&#39; new website</p></div><p>Another example is <a
href="http://www.atebits.com/">Atebits&#8217;</a> website. Atebits is the company behind the Twitter app <a
title="Tweetie for Mac" href="http://www.atebits.com/tweetie-mac/">Tweetie</a>. Let&#8217;s have a look at their front page:</p><div
id="attachment_372" class="wp-caption alignnone" style="width: 510px"><a
href="http://atebits.com/"><img
class="size-full wp-image-372" title="Atebits' website" src="http://stiern.com/site/wp-content/everything/Billede-5.png" alt="Atebits' website" width="500" height="345" /></a><p
class="wp-caption-text">Atebits&#39; website</p></div><p>That&#8217;s just beautiful, huh? Well, let&#8217;s dive into how we easily can add similar function to our own site.</p><p>The first property we have to learn is <code>-webkit-transition</code>. The <code>-webkit-transition</code> property is a shortcode for the three properties <code>-webkit-transition-property</code>, <code>-webkit-transition-duration</code> and <code>-webkit-transition-timing-function</code>.</p><p>We&#8217;ll probably learn this the best by having a look at an example, so here goes: We want to create a div that, when hovered, fades into another color. Here&#8217;s the code:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">div <span style="color: #00AA00;">&#123;</span>
  -webkit-transition<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">color</span> 0.4s linear<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#777777</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>And here&#8217;s the example:</p><div
class="webkitarticle">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div><p>This wasn&#8217;t so hard, was it? Now let&#8217;s move on to using the <code>-webkit-transform</code> property. It allows you to scale, rotate, translate, and skew the object. It even allows you to use matrices for advanced transformations. Let&#8217;s try to rotate and skew the div from before:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">div <span style="color: #00AA00;">&#123;</span>
  -webkit-transition<span style="color: #00AA00;">:</span> all 0.4s linear<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#777777</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  -webkit-transform<span style="color: #00AA00;">:</span> scale<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">1.3</span><span style="color: #00AA00;">&#41;</span> skew<span style="color: #00AA00;">&#40;</span>3deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><div
class="webkitarticle2">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div><p>This is just a little glimpse into what you can do with WebKit. Hopefully, you&#8217;ll find it useful.</p><p><span
style="color: #ffffff;">i55iqj8amt</span></p><p>Related posts:<ol><li><a
href='http://stiern.com/tutorials/create-a-cool-messy-list-with-css3-and-nth-child' rel='bookmark' title='Permanent Link: Create a Cool Messy List with CSS3 and nth-child'>Create a Cool Messy List with CSS3 and nth-child</a></li><li><a
href='http://stiern.com/articles/5-cool-ways-to-add-graphs-to-your-website' rel='bookmark' title='Permanent Link: 5 Cool Ways to Add Graphs to Your Website'>5 Cool Ways to Add Graphs to Your Website</a></li><li><a
href='http://stiern.com/tutorials/adding-custom-google-maps-to-your-website' rel='bookmark' title='Permanent Link: Adding Custom Google Maps to Your Website'>Adding Custom Google Maps to Your Website</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/enhancing-your-site-with-webkit/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Lights and Shadows in Photoshop</title><link>http://stiern.com/tutorials/lights-and-shadows-in-photoshop</link> <comments>http://stiern.com/tutorials/lights-and-shadows-in-photoshop#comments</comments> <pubDate>Fri, 03 Jul 2009 13:53:43 +0000</pubDate> <dc:creator>Andreas</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Graphic Design]]></category> <category><![CDATA[Photoshop]]></category><guid
isPermaLink="false">http://stiern.com/?p=336</guid> <description><![CDATA[This tutorial is not too advanced but mostly to help to understand the power of shadow and light in short terms! There’s no “boring” text here. So if you are not used to Photoshop, do yourself a favor and read it all before continuing to the next step! You might learn something! The thing about [...]]]></description> <content:encoded><![CDATA[<p></p><p>This tutorial is not too advanced but mostly to help to understand the power of shadow and light in short terms! There’s no “boring” text here. So if you are not used to Photoshop, do yourself a favor and read it all before continuing to the next step! You might learn something!</p><p><span
id="more-336"></span></p><p></p><p>The thing about a good picture is to give it a feel of depth. You need not to give the receiver any reason to speculate whether a shadow is placed weird or a light source is coming in at a wrong angle. Often I can even find shadows and light sources in non edited pictures that look unreal. That is mostly in very poorly illuminated pictures.</p><p>In this picture you have an idea of where the light source comes from. Still it could handle a bit more tension and depth!</p><div
id="attachment_338" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/lights_and_shadows_noned.png"><img
class="size-full wp-image-338" src="http://stiern.com/site/wp-content/everything/lights_and_shadows_noned.png" alt="lights_and_shadows_noned" width="500" height="334" /></a><p
class="wp-caption-text">The initial picture</p></div><p>To bring the picture to life, we will add some depth and sharpness. Too much editing can destroy a picture as well, so be careful not to gaze too long at your editing. Your effects and layers could end indifferent to others!</p><p>Let’s see if we can end here:</p><div
id="attachment_397" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/lights_and_shadows_done.png"><img
class="size-full wp-image-397  " src="http://stiern.com/site/wp-content/everything/lights_and_shadows_done.png" alt="The final picture" width="500" height="334" /></a><p
class="wp-caption-text">The final picture</p></div><p>The retouching gives the receiver no reason to doubt as to where the light source is coming from.</p><p>Let’s get to it!</p><p>And don’t worry about naming the layers. We’ll not end up with more than 5 or 6 of them. I’m usually really sloppy when it comes to naming layers. It’s the last thing I do so that I can jump right into it if need be later on.</p><h3>Step 1</h3><p>Open your picture.</p><div
id="attachment_404" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/las_open.png"><img
class="size-full wp-image-404  " src="http://stiern.com/site/wp-content/everything/las_open.png" alt="Open your picture in Photoshop" width="500" height="305" /></a><p
class="wp-caption-text">Open your picture in Photoshop</p></div><h3>Step 2</h3><p>Take your <em>clone stamp tool</em> (hotkey <em>s</em>). Now hold down the <em>alt</em> key and choose a suiteable area of skin you want to clone from. Run the mouse over the part you want to edit and click. We don’t ”clean” up the impurities in the skin because they&#8217;re ”unnatural”, but because they will end up standing out too much at the final outcome if we don’t.</p><div
id="attachment_406" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/las_4.png"><img
class="size-full wp-image-406 " src="http://stiern.com/site/wp-content/everything/las_4.png" alt="las_4" width="500" height="310" /></a><p
class="wp-caption-text">Use the clone tool to remove impurities</p></div><h3>Step 3</h3><p>Now take your <em>dodge tool</em> (hotkey <em>o</em>, the black lollipop) and remember to set your <strong><em><span
style="font-weight: normal">range</span></em></strong> to midttones and your <em>opacity</em> to somewhat in the 60’s (in this example). Gently affect the eyes where the light would hit them. Most often in the lower part or the whole eye. Remember not too much, even if it looks cool. We want it to look natural!</p><div
id="attachment_414" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/las_dodge.png"><img
class="size-full wp-image-414  " src="http://stiern.com/site/wp-content/everything/las_dodge.png" alt="Use the dodge tool to simulate light" width="500" height="305" /></a><p
class="wp-caption-text">Use the dodge tool to simulate light</p></div><h3>Step 4</h3><p>Press the <em>New ajustment layer</em> button or go <em>Layer » New Ajustment Layer » Curves</em> . Now go 1/6’th up the curve and drag it down until the result is pleasing. Fill the layer with 60% black. Choose a brush with opacity of approximately 25% and a flow of about 60% and go easily around the dark areas with a reasonable large brush for the cheekbones and neck. Use a smaller brush for the lines at the eyes, the mouth, the nose etc.</p><div
id="attachment_415" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/las_curves.png"><img
class="size-full wp-image-415 " src="http://stiern.com/site/wp-content/everything/las_curves.png" alt="Create a new adjustment layer" width="500" height="305" /></a><p
class="wp-caption-text">Create a new adjustment layer</p></div><h3>Step 5</h3><p>Now repeat Step 4. But this time with lights instead of the shadows. That means make a new Curves layer, fill with 60% black, go 1/6’th down the curve from the top, and pull it up until the result is pleasing. For the brush part, just repeat step 4. If you need more effect with the brush choose a higher opacity setting.</p><div
id="attachment_416" class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/las_curves2.png"><img
class="size-full wp-image-416 " src="http://stiern.com/site/wp-content/everything/las_curves2.png" alt="Create another adjustment layer" width="500" height="305" /></a><p
class="wp-caption-text">Create another adjustment layer</p></div><h3>Step 6</h3><p>Now the more fun part. The ”effect”. Go <em>Layer » New Ajustment Layer » Gradient Map</em>. Select <em>Dither</em> and make sure you set the Layer setting to <em>overlay</em> and approximately 35-50% <em>opacity</em>, but again, that depends what picture you are working on, how dark the colors are, how big the picture is, etc. Play around with the gradient a little to find out which one matches your picture the best. (Look at the eyes popping out now. If you brought them out too much at the beginning they would look surreal by now, and we don’t want that.)</p><div
id="attachment_417" class="wp-caption alignnone" style="width: 510px"><a
href="http://stiern.com/site/wp-content/everything/las_adjust.png"><img
class="size-full wp-image-417 " src="http://stiern.com/site/wp-content/everything/las_adjust.png" alt="Let's start making the actual effect" width="500" height="305" /></a><p
class="wp-caption-text">Let&#39;s start making the actual effect</p></div><h3>Step 7</h3><p>Select the all layers (except you source picture) and group them  <em>Cmd+G</em> (<em>Ctrl+G</em> on Windows). Right click and duplicate group. Next you need to merge the new group, so go <em>Cmd+E</em> (<em>Ctrl+E </em>on Windows).</p><p>Now go<strong> </strong><em>Filter » Other » High Pass</em> and set it to about 4 and a layer setting of <em>overlay</em>. Again, that setting depends on the size, content, quality etc. of the picture. This <em>High Pass</em> filter is to sharpen up the image. This will do a lot to the eyes for example, but you can see for yourself.</p><h3>Step 8</h3><p>With the <em>High Pass</em> layer now selected I would, no matter what picture you are retouching, go <em>Layer » Layer Mask » Reveal All.</em> Get the <em>Brush tool</em><strong> </strong>with 60% opacity and 60% black and go over the largest areas. In my picture it would be the cheek, grass and the shirt. Go over the things that should not be striking to the eye at first when looking at the picture.</p><h3>Step 9</h3><p><span
style="font-weight: normal;font-size: 13px">Clean it up, maybe add some more light or shadow if your image can handle it.</span></p><h3>That&#8217;s it</h3><div
class="wp-caption alignnone" style="width: 510px"><a
rel="lightbox" href="http://stiern.com/site/wp-content/everything/lights_and_shadows_done.png"><img
src="http://stiern.com/site/wp-content/everything/lights_and_shadows_done.png" alt="The final picture" width="500" height="334" /></a><p
class="wp-caption-text">The final picture</p></div><p>Hope you learned something! Take care!</p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/lights-and-shadows-in-photoshop/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Changing the Size of the Avatar in WordPress 2.7</title><link>http://stiern.com/tutorials/changing-the-size-of-the-avatar-in-wordpress-27</link> <comments>http://stiern.com/tutorials/changing-the-size-of-the-avatar-in-wordpress-27#comments</comments> <pubDate>Wed, 07 Jan 2009 11:45:03 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Wordpress]]></category> <category><![CDATA[Avatar]]></category> <category><![CDATA[Comments]]></category><guid
isPermaLink="false">http://stiern.com/?p=159</guid> <description><![CDATA[The default size of an avatar is 32x32px, which I think is a bit small. Therefore, I&#8217;d like to change it to 60x60px instead. But back in the good ol&#8217; 2.6 days, and of course also earlier, changing the size of an avatar (the little picture shown e.g. in comments) was a pain. Now, with [...]]]></description> <content:encoded><![CDATA[<p>The default size of an avatar is 32x32px, which I think is a bit small. Therefore, I&#8217;d like to change it to 60x60px instead. But back in the good ol&#8217; 2.6 days, and of course also earlier, changing the size of an avatar (the little picture shown e.g. in comments) was a pain. Now, with WordPress 2.7 it&#8217;s easier than ever!</p><p><span
id="more-159"></span></p><p>And while we&#8217;re at it, remember to get yourself a <a
href="http://gravatar.com/" title="Gravatar">gravatar</a>.</p><p>In your theme, open the comments.php and look for the following code:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_comments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><p>This simple line of code has a massive amount of options available. If you want to learn more about them, head over to the <a
title="Wordpress Codex - wp_list_comments" href="http://codex.wordpress.org/Template_Tags/wp_list_comments">WordPress Codex pages</a> and check them out. For now, we&#8217;ll just concentrate on changing the size of the avatar.</p><p>The way we can do this, is simply by adding some text inside the function, like this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'avatar_size=60'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><p>After that… No, actually there is no after that! By doing this, the avatar&#8217;s size will be changed to 60px.</p><p>Related posts:<ol><li><a
href='http://stiern.com/tutorials/no-more-invalid-rss' rel='bookmark' title='Permanent Link: No More Invalid RSS'>No More Invalid RSS</a></li><li><a
href='http://stiern.com/articles/css3-is-not-freaking-html5' rel='bookmark' title='Permanent Link: CSS3 is Not Freaking HTML5'>CSS3 is Not Freaking HTML5</a></li><li><a
href='http://stiern.com/tutorials/adding-custom-google-maps-to-your-website' rel='bookmark' title='Permanent Link: Adding Custom Google Maps to Your Website'>Adding Custom Google Maps to Your Website</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/changing-the-size-of-the-avatar-in-wordpress-27/feed</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>No More Invalid RSS</title><link>http://stiern.com/tutorials/no-more-invalid-rss</link> <comments>http://stiern.com/tutorials/no-more-invalid-rss#comments</comments> <pubDate>Sun, 04 Jan 2009 00:27:37 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Wordpress]]></category> <category><![CDATA[RSS]]></category><guid
isPermaLink="false">http://stiern.com/?p=147</guid> <description><![CDATA[When I made this site, I spend hours figuring out why my feed wasn&#8217;t working. There are several examples in the WordPress Support Forums telling, that feeds aren&#8217;t working because of a blank line in the beginning of the feed before the XML declaration. Some feedreaders have no problem with this, but Feedburner does. And [...]]]></description> <content:encoded><![CDATA[<p>When I made this site, I spend hours figuring out why my feed wasn&#8217;t working. There are several examples in the WordPress Support Forums telling, that feeds aren&#8217;t working because of a blank line in the beginning of the feed before the XML declaration. Some feedreaders have no problem with this, but <a
title="feedburner" href="http://feedburner.com/">Feedburner</a> does. And Feedburner is very important.</p><p><span
id="more-147"></span></p><p>Well, let&#8217;s get to it! The fix was found at <a
title="Wejn.org" href="http://wejn.org/">Wejn.org</a> and is very simple to use. First of all, you need to download the script file, called <a
title="Wejnswpwhitespacefix" href="http://wejn.org/stuff/wejnswpwhitespacefix.php.html">wejnswpwhitespacefix.php</a> and upload it to your blog&#8217;s root (in the same folder as index.php. Then, get your index.php file. It usually looks something like this:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_USE_THEMES'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** Loads the WordPress Environment and Template */</span>
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'./site/wp-blog-header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><p>Now, right before <code>define('WP_USE_THEMES', true);</code>, add <code>include("wejnswpwhitespacefix.php");</code>.</p><p>This will call the script, which removes every character that isn&#8217;t text before the XML declaration in the RSS files, and before the DOCTYPE declaration in the theme files.</p><p>Related posts:<ol><li><a
href='http://stiern.com/stierncom/welcome' rel='bookmark' title='Permanent Link: Welcome to Stiern.com'>Welcome to Stiern.com</a></li><li><a
href='http://stiern.com/tutorials/installing-concrete5-locally-on-mac-os-x' rel='bookmark' title='Permanent Link: Installing Concrete5 locally on Mac OS X'>Installing Concrete5 locally on Mac OS X</a></li><li><a
href='http://stiern.com/tutorials/how-to-use-directions-with-google-maps-api-v3' rel='bookmark' title='Permanent Link: How to Use Directions with Google Maps API V3'>How to Use Directions with Google Maps API V3</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/no-more-invalid-rss/feed</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Installing Concrete5 locally on Mac OS X</title><link>http://stiern.com/tutorials/installing-concrete5-locally-on-mac-os-x</link> <comments>http://stiern.com/tutorials/installing-concrete5-locally-on-mac-os-x#comments</comments> <pubDate>Tue, 30 Dec 2008 13:57:52 +0000</pubDate> <dc:creator>Peter</dc:creator> <category><![CDATA[Concrete5]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[CMS]]></category> <category><![CDATA[Content Management]]></category> <category><![CDATA[Mac OS X]]></category> <category><![CDATA[MAMP]]></category><guid
isPermaLink="false">http://stiern.com/new/?p=19</guid> <description><![CDATA[If you don&#8217;t have your own webserver, or if you don&#8217;t want to waste your traffic on uploading your files everytime you make a small edit, you should consider running it all locally, and then when you&#8217;re done uploading it to your server. It&#8217;s no secret that I&#8217;m a big fan of WordPress, and I [...]]]></description> <content:encoded><![CDATA[<p>If you don&#8217;t have your own webserver, or if you don&#8217;t want to waste your traffic on uploading your files everytime you make a small edit, you should consider running it all locally, and then when you&#8217;re done uploading it to your server.</p><p>It&#8217;s no secret that I&#8217;m a big fan of <a
title="wordpress" href="http://www.wordpress.org">WordPress</a>, and I have been using it for ages. But for some clients, WordPress is overkill. There&#8217;s a lot of Content Management Systems out there, and a lot of them suck, lack features, or have too many features. But then I found Concrete5, which is absolutely amazing.</p><p><span
id="more-19"></span></p><p>But enough about that (go to <a
title="concrete5s_website" href="http://concrete5.org/" target="_blank">Concrete5&#8242;s website</a> to read more). Today we&#8217;ll be installing Concrete5 locally. Although this tutorial is about installing Concrete5, you can use the same methods to install e.g. <a
title="wordpress" href="http://www.wordpress.org/" target="_blank">WordPress</a>, <a
title="joomla" href="http://www.joomla.org/" target="_blank">Joomla</a>, <a
title="drupal" href="http://drupal.org/" target="_blank">Drupal</a>, or even your own content management system.</p><p>The methods used here can also be used for installing Concrete5 locally on Windows and Linux. Instead of MAMP, you have to use <a
title="wamp" href="http://www.wampserver.com/en/download.php" target="_blank">WAMP</a> (Windows) or <a
title="lamp" href="http://www.linuxhelp.net/guides/lamp/" target="_blank">LAMP</a> (Linux).</p><h3>Overview</h3><p><a
title="mamp" href="http://www.mamp.info/en/index.php" target="_blank">MAMP</a> (Macintosh, Apache, MySQL and PHP) is a piece of software developed by <a
title="living-e_ag" href="http://living-e.de/en/index.php" target="_blank">living-e AG</a>, which makes using PHP and MySQL locally a lot easier. First of all, let&#8217;s start by having an overview of what we&#8217;ll be learning today:</p><ol><li><a
href="#di_mamp">Downloading and installing MAMP</a></li><li><a
href="#di_concrete">Downloading and installing Concrete5</a></li><li><a
href="#conclusion">Conclusion</a></li></ol><p>And no, there&#8217;s not more to it &#8211; so let&#8217;s get rollin&#8217;!<br
/> <a
name="di_mamp"></a></p><h3>Downloading and installing MAMP</h3><p><a
title="download_mamp" href="http://www.mamp.info/en/download.html" target="_blank">Download MAMP</a> (130 MB) and drag the MAMP folder into your Applications folder.<a
title="download_mamp" href="http://www.mamp.info/en/download.html" target="_blank"></a> Opening MAMP will also launch your default browser with a welcome page. We&#8217;ll return to that in a moment. First, let&#8217;s have a look at the application. If everything is working, you should see to green &#8216;lamps&#8217; &#8211; one for Apache Server and one for MySQL server. Click on &#8216;Preferences&#8230;&#8217; and go to the &#8216;Apache&#8217; tab. You&#8217;ll see this:</p><p><a
class="postimg" title="The Apache tab in MAMP" href="http://stiern.com/site/wp-content/everything/2008/12/apache_tab-300x197.png"><img
class="size-medium wp-image-38 alignnone" title="apache_tab" src="http://stiern.com/site/wp-content/everything/2008/12/apache_tab-300x197.png" alt="The Apache tab in MAMP" /></a></p><p>Choose the path where you keep all your websites and hit &#8216;OK&#8217;. There&#8217;s no reason to mess with MAMP&#8217;s default settings unless you e.g. use the default ports for something else, so we&#8217;ll close the &#8216;Preferences&#8217; window.</p><p>Go to your browser, which should have opened the welcome page. We&#8217;ll keep that page open.</p><h3><a
name="di_concrete"></a>Downloading and installing Concrete5</h3><p>If you haven&#8217;t heard of Concrete5, now&#8217;s the time. It&#8217;s a wonderful CMS released under the MIT license, which means you can &#8220;<a
title="get-started" href="http://www.concrete5.org/get-started/" target="_blank"><em>[...] call it &#8216;Cement&#8217; and sell it for a million bucks [...]</em></a>&#8220;. So, go to <a
title="concrete5" href="http://www.concrete5.org/" target="_blank">Concrete5.org</a> and download your copy. You can also play with the demo or watch the screencast.</p><p>Extract Concrete5 to the folder you specified in MAMP&#8217;s preferences. Now, go back to MAMP&#8217;s welcome page and click on phpMyAdmin. Create a new database &#8211; let&#8217;s call it <em>concrete</em>.</p><p><a
class="postimg" title="Create a new database with the name 'concrete'" href="http://stiern.com/site/wp-content/everything/2008/12/create_new_database.png"><img
class="size-medium wp-image-42 alignnone" src="http://stiern.com/site/wp-content/everything/2008/12/create_new_database.png" alt="Create a new database with the name 'concrete'" /></a></p><p>So, our database is setup, now we need to setup Concrete5. I put my Concrete5 files in a folder called &#8216;concrete&#8217; in the folder specified in MAMP earlier. Go to MAMP&#8217;s welcome page again, and notice the following information:</p><p><a
class="postimg" title="Useful info at the welcome page" href="http://stiern.com/site/wp-content/everything/2008/12/welcome_page_1.png"><img
class="size-medium wp-image-39 alignnone" src="http://stiern.com/site/wp-content/everything/2008/12/welcome_page_1.png" alt="Useful info at the welcome page" width="140" height="98" /></a></p><p>Go to the local folder where you stored concrete, and press Command + I. You have to change Sharing &amp; Permissions for Everyone to Read &amp; Write:</p><p><a
class="postimg" title="Change Sharing &amp; Permissions for Everyone to Read &amp; Write" href="http://stiern.com/site/wp-content/everything/2008/12/read_and_write.png"><img
class="size-medium wp-image-51 alignnone" src="http://stiern.com/site/wp-content/everything/2008/12/read_and_write.png" alt="Change Sharing &amp; Permissions for Everyone to Read &amp; Write" /></a></p><p>Now go to http://localhost:8888/concrete/, or whatever you named your folder (if you chose another port in MAMP&#8217;s preferences, also change 8888 to that). You&#8217;ll see this site:</p><p><a
class="postimg" title="The setup screen for Concrete5" href="http://stiern.com/site/wp-content/everything/2008/12/concrete_setup.png"><img
class="size-thumbnail wp-image-44 alignnone" src="http://stiern.com/site/wp-content/everything/2008/12/concrete_setup-150x150.png" alt="The setup screen for Concrete5" /></a></p><p>Now, paste the information from the welcome page under &#8216;Database&#8217; information, and give your database a name, e.g. &#8216;concrete&#8217;, and hit &#8216;Install Concrete&#8217;. You should now be given a login name and a password. Remember this, and change it as soon as you have logged in.<br
/> <a
name="conclusion"></a></p><h3>Conclusion</h3><p>That&#8217;s it! You have installed Concrete5 locally on Mac OS X. If you want to install other stuff, just put it in the folder specified in MAMP and go to http://localhost:8888/that_folders_name/.</p><p>Have I forgotten something? Please leave a comment!</p><p>Related posts:<ol><li><a
href='http://stiern.com/tutorials/no-more-invalid-rss' rel='bookmark' title='Permanent Link: No More Invalid RSS'>No More Invalid RSS</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://stiern.com/tutorials/installing-concrete5-locally-on-mac-os-x/feed</wfw:commentRss> <slash:comments>32</slash:comments> </item> </channel> </rss> <br
/> <b>Fatal error</b>:  Cannot redeclare class JSMin in <b>/home/www/stiern.com/site/wp-content/plugins/w3-total-cache/lib/Minify/JSMin.php</b> on line <b>53</b><br
/>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 52/205 queries in 0.586 seconds using disk

Served from: stiern.com @ 2010-09-07 17:41:01 -->