<?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>Tony Thomas</title>
	<atom:link href="http://anthonygthomas.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://anthonygthomas.com</link>
	<description>Father to two, husband to one, web developer and musician.</description>
	<lastBuildDate>Fri, 27 Apr 2012 19:26:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Media Queries for High Pixel-density Devices</title>
		<link>http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/</link>
		<comments>http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 23:46:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[media queries]]></category>
		<category><![CDATA[Mobile Technology]]></category>
		<category><![CDATA[responsive design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=689</guid>
		<description><![CDATA[Images continue to be a major challenge for mobile web development. I&#8217;ve written about a technique to evaluate screen dimensions and pixel-density using JavaScript. I recently came across some vendor-prefixed media queries to evaluate screen density right in your CSS. (Hat tip to Erik Runyon.) The technique involves creating two sets of background images. One [...]]]></description>
			<content:encoded><![CDATA[<p>Images continue to be a major challenge for mobile web development. <a href="http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/">I&#8217;ve written about a technique to evaluate screen dimensions and pixel-density using JavaScript</a>. I recently came across some vendor-prefixed media queries to evaluate screen density right in your CSS. (<a href="http://weedygarden.net/2010/10/retina-display-and-css-background-images/" onclick="pageTracker._trackPageview('/outgoing/weedygarden.net/2010/10/retina-display-and-css-background-images/?referer=');">Hat tip to Erik Runyon</a>.)</p>
<p>The technique involves creating two sets of background images. One standard-sized version and a double-sized version (@2x) for high pixel-density screens like the Retina display or Droid phone display.<span id="more-689"></span> For the purposes of this example, let&#8217;s say I have a default icon that&#8217;s 50px X 50px.</p>
<pre class="brush: css; title: ; notranslate">#link-id a { background-image:url(images/icon.png); }</pre>
<p>The Motorola Droid has a pixel-density of 1.5 so I set that as my baseline.</p>
<pre class="brush: css; title: ; notranslate">@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
	only screen and (-o-min-device-pixel-ratio: 3/2),
	only screen and (min--moz-device-pixel-ratio: 1.5),
	only screen and (min-device-pixel-ratio: 1.5) {
		#link-id a {
			background-image:url(images/icon@2x.png);
		}
}</pre>
<p>Notice the subtle difference in how the ratio is calculated for Opera. Also, Mozilla&#8217;s vendor prefix has a slightly different syntax. I&#8217;m following Erik Runyon&#8217;s advise here and using Apple&#8217;s style guidelines by naming the hi-res icon with the same name as my normal-resolution icon, but with <code>@2x</code> appended. In this case, the &#8220;@2x&#8221; version is 100px X 100px. The next thing you&#8217;ll have to do is scale the hi-res icon down.</p>
<pre class="brush: css; title: ; notranslate">background-size: 50px 50px;</pre>
<p>That&#8217;s it. Now high pixel-density devices will render a suitably high-resolution image and normal-resolution devices will get a smaller image.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/" rel="bookmark" title="April 22, 2012">Media Queries for High Pixel-density Devices</a></li>
<li><a href="http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/" rel="bookmark" title="February 16, 2012">Responsive Images: Keep It Simple; Keep It Small</a></li>
<li><a href="http://anthonygthomas.com/2012/02/28/one-site/" rel="bookmark" title="February 28, 2012">One Site</a></li>
<li><a href="http://anthonygthomas.com/2011/03/05/when-to-use-the-css-content-property/" rel="bookmark" title="March 5, 2011">When to Use CSS content Property</a></li>
<li><a href="http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/" rel="bookmark" title="November 26, 2008">Getting Blueprint CSS &#038; JavaScript Libraries Into Your CakePHP Layout</a></li>
</ul>
<p><!-- Similar Posts took 4.352 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Impress.js</title>
		<link>http://anthonygthomas.com/2012/03/09/using-impress-js/</link>
		<comments>http://anthonygthomas.com/2012/03/09/using-impress-js/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 17:08:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=678</guid>
		<description><![CDATA[Update: There is at least one WYSIWYG impress.js editor available now. I came across Impress.js a while back and I was, well, impressed. It makes sense to do presentations on the web, given the powerful animations and transitions available in modern browsers. Impress is sort of like Prezi improved. Improved because it takes advantage of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> <a href="http://www.hsivaram.com/impressionist/alpha3/" onclick="pageTracker._trackPageview('/outgoing/www.hsivaram.com/impressionist/alpha3/?referer=');">There is at least one WYSIWYG impress.js editor available now</a>.</p>
<p>I came across <a href="http://bartaz.github.com/impress.js/#/bored" onclick="pageTracker._trackPageview('/outgoing/bartaz.github.com/impress.js/_/bored?referer=');">Impress.js</a> a while back and I was, well, <em>impressed</em>. It makes sense to do presentations on the web, given the powerful animations and transitions available in modern browsers. Impress is sort of like <a href="http://prezi.com/" onclick="pageTracker._trackPageview('/outgoing/prezi.com/?referer=');">Prezi</a> <em>improved</em>. Improved because it takes advantage of 3d animation. It does require some technical skill however. You need to know a bit about HTML5 and you have to be able to code a web page and write styles.</p>
<p>Right now you can only learn how to use Impress.js by reading the comments and experimenting. I thought it might be good to go through each of the features here to give a sense of it&#8217;s capabilities. If you&#8217;re interested, there aren&#8217;t really any insights here that you can&#8217;t find in the source.<span id="more-678"></span></p>
<p>The first thing is that you have to have a story to tell. Impress.js does nothing for you if you don&#8217;t have a narrative. So plan out what you want to say. Personally, write out what I want to say in any presentation in prose first. Just words. That way I can get a cohesive narrative going with good verbal transitions. Then I think about the visual stuff.</p>
<p>Assuming you know what you want to say, let&#8217;s move on.</p>
<p>First you&#8217;ll need to <a href="https://github.com/bartaz/impress.js" onclick="pageTracker._trackPageview('/outgoing/github.com/bartaz/impress.js?referer=');">download the JavaScript</a>. Next set up an HTML document with the HTML5 doctype. (Impress.js takes advantage of HTML5&#8242;S <code>data</code> attribute, so HTML5 is necessary.)</p>
<pre class="brush: xml; title: ; notranslate">&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Impress.js Presentation&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;impress&quot;&gt;
&lt;/div&gt;
&lt;!-- Put the script at the bottom --&gt;
&lt;script src=&quot;js/impress.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;impress();&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>The slides need to go into an element with the id of &#8220;impress.&#8221; It&#8217;s a div above, but it can be anything. The comments in the source also suggest adding the class, &#8220;impress-not-supported&#8221; to the <code>#impress</code> div. This class will be added if the browser does not support impress, but it&#8217;s good to have it there for browsers without JavaScript enabled. <code>impress-not-supported</code> allows you to provide a fallback message.</p>
<h3>Options</h3>
<p>Now things get interesting. Each slide should be within <code>#impress</code> and have a class of &#8220;step.&#8221; Positioning information is stored in <code>data</code> attributes. First off are the x and y coordinates. It&#8217;s important to note that we&#8217;re defining the x and y coordinates of the <em>center</em> of the element in question.</p>
<pre class="brush: xml; title: ; notranslate">&lt;div class=&quot;slide&quot; data-x=&quot;-1500&quot; data-y=&quot;-1000&quot;&gt;&lt;p&gt;Our first slide&lt;/p&gt;&lt;/div&gt;</pre>
<p>You can give you slides ids so you can link to a particular slide. Id&#8217;s are not required, however. If you don&#8217;t add them, impress.js will add a #step-N id to each element and append the hash to the url. While a hash syntax of <code>#/step-N</code> will still work, it&#8217;s better to use a standard hash like <code>#step-N</code> so that links will still work without JavaScript.</p>
<p>The next dimension we can control is scale:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;title&quot; class=&quot;step&quot; data-x=&quot;0&quot; data-y=&quot;0&quot; data-scale=&quot;4&quot;&gt;&lt;p&gt;Slide content&lt;/p&gt;&lt;/div&gt;</pre>
<p>Note the <code>data-scale</code> attribute above. In this case, the slide is scaled down by a factor of 4, then scaled up to full-scale during the transition.</p>
<p>We can also control rotation:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;its&quot; class=&quot;step&quot; data-x=&quot;850&quot; data-y=&quot;3000&quot; data-rotate=&quot;90&quot; data-scale=&quot;5&quot;&gt;&lt;p&gt;Slide Content&lt;/p&gt;</pre>
<p>For this, use <code>data-rotate</code>. In the example above, the slide is rotated 90 degrees.</p>
<p>And now we go 3d:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;tiny&quot; class=&quot;step&quot; data-x=&quot;2825&quot; data-y=&quot;2325&quot; data-z=&quot;-3000&quot; data-rotate=&quot;300&quot; data-scale=&quot;1&quot;&gt;&lt;p&gt;Slide content.&lt;/p&gt;&lt;/div&gt;</pre>
<p>The <code>data-z</code> attribute above places this slide 3000 pixels away along the z-index.</p>
<p>Finally, we can control rotation along axes:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;its-in-3d&quot; class=&quot;step&quot; data-x=&quot;6200&quot; data-y=&quot;4300&quot; data-z=&quot;-100&quot; data-rotate-x=&quot;-40&quot; data-rotate-y=&quot;10&quot; data-scale=&quot;2&quot;&gt;&lt;p&gt;</pre>
<p>Those are the options. I had a little fun creating a <a href="/impress/resume/">version of my r&eacute;sum&eacute;</a>. It&#8217;s pretty fun. I can also see some storytelling potential with this. Go forth and impress!<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/03/09/using-impress-js/" rel="bookmark" title="March 9, 2012">Using Impress.js</a></li>
<li><a href="http://anthonygthomas.com/2011/03/12/simple-rss-parsing-and-caching-using-php/" rel="bookmark" title="March 12, 2011">Simple RSS Parsing and Caching Using PHP</a></li>
<li><a href="http://anthonygthomas.com/2010/05/24/an-unexpected-problem-with-cakephp-and-email-elements/" rel="bookmark" title="May 24, 2010">An Unexpected Problem with CakePHP and Email Elements</a></li>
<li><a href="http://anthonygthomas.com/2008/12/10/use-functions-from-other-controllers-while-maintaining-mvc-architecture-in-cakephp/" rel="bookmark" title="December 10, 2008">Use Functions from Other Controllers While Maintaining MVC Architecture in CakePHP</a></li>
<li><a href="http://anthonygthomas.com/2009/07/22/simple-security-in-cakephp/" rel="bookmark" title="July 22, 2009">Simple Security in CakePHP</a></li>
</ul>
<p><!-- Similar Posts took 4.320 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/03/09/using-impress-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun With JQuery Tubular</title>
		<link>http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/</link>
		<comments>http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 20:39:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=670</guid>
		<description><![CDATA[I came across Sean McCambridge&#8217;s JQuery Tubular plugin a while back and I thought it would be fun to experiment with it. So I set up a little demo and I thought I&#8217;d walk through it here. I should say that it wasn&#8217;t until I came across Phil Plait&#8217;s amazing moon simulation that I was [...]]]></description>
			<content:encoded><![CDATA[<p>I came across <a href="http://www.seanmccambridge.com/" onclick="pageTracker._trackPageview('/outgoing/www.seanmccambridge.com/?referer=');">Sean McCambridge&#8217;s</a> <a href="http://www.seanmccambridge.com/tubular/" onclick="pageTracker._trackPageview('/outgoing/www.seanmccambridge.com/tubular/?referer=');">JQuery Tubular</a> plugin a while back and I thought it would be fun to experiment with it. <a href="/examples/tubular/tubular.html">So I set up a little demo</a> and I thought I&#8217;d walk through it here.</p>
<p>I should say that it wasn&#8217;t until I came across <a href="http://blogs.discovermagazine.com/badastronomy/2012/03/02/nasa-goddard-rocks-the-moon/" onclick="pageTracker._trackPageview('/outgoing/blogs.discovermagazine.com/badastronomy/2012/03/02/nasa-goddard-rocks-the-moon/?referer=');">Phil Plait&#8217;s amazing moon simulation</a> that I was inspired to build the demo.</p>
<p>I should also say that my example is completely unnecessary given Sean&#8217;s documentation. It&#8217;s really as simple as this:</p>
<pre class="brush: jscript; title: ; notranslate">$('body').tubular('someYTid','video'); // where someYTid is the YouTube ID and wrapper is your containing DIV.</pre>
<p>Once you have JQuery and JQuery Tubular linked in the head of your document and replace &#8216;someYTid&#8217; with the id of your YouTube video, it will just work. The rest is styling. In the interest of explaining things all in one place, I&#8217;ll walk through what I did.<span id="more-670"></span></p>
<p>First, you need to set up the JQuery Tubular plugin and dependencies in your document:</p>
<pre class="brush: xml; title: ; notranslate">&lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src=&quot;//html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;js/jquery.tubular.js&quot;&gt;&lt;/script&gt;</pre>
<p>I&#8217;ve loaded JQuery using <a href="http://code.google.com/apis/libraries/devguide.html" onclick="pageTracker._trackPageview('/outgoing/code.google.com/apis/libraries/devguide.html?referer=');">Google&#8217;s CDN</a>, <a href="http://code.google.com/p/html5shiv/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/html5shiv/?referer=');">HTML5 Shiv</a> (because I&#8217;m using the HTML5 Doctype), <a href="http://code.google.com/p/swfobject/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/swfobject/?referer=');">SWFObject</a> and the JQuery Tubular plugin linked above.</p>
<p>Next I set up a few styles. First I load some Google-hosted fonts:</p>
<pre class="brush: xml; title: ; notranslate">&lt;link href='http://fonts.googleapis.com/css?family=Stardos+Stencil|Muli&amp;v2' rel='stylesheet' type='text/css'&gt;</pre>
<p>Then I added a few styles of my own. (This is the &#8220;style to taste&#8221; portion.)</p>
<pre class="brush: css; title: ; notranslate">/* Use Stardos Stencil for headings */
h1, h2, h3, h4, h5, h6 {
	font-family: 'Stardos Stencil', cursive;
	font-style: normal;
	font-weight: 400;
	font-size: 64px;
	text-transform: none;
	text-decoration: none;
	letter-spacing: 0em;
	word-spacing: 0em;
	line-height: 1.4;
}
/* links are white and bold */
a {
	color: #fff;
	font-weight: bold;
}
/* Give the body a black background and get rid of browser-default margins and padding */
body {
	background: #000;
	margin: 0;
	padding: 0;
}
/* Any text needs to use absolute positioning and have a high z-index to float above the background video */
h1 {
	color: #fff;
	font-size: 1.2em;
	font-weight: bold;
	position: absolute;
	right: 20px;
	top: 20px;
	z-index: 1000;
}
/* Use Muli for paragraphs and set up absolute positioning and high z-index */
p {
	color: #fff;
	font-family: 'Muli', sans-serif;
	font-style: normal;
	font-weight: 400;
	font-size: 13px;
	left: 20px;
	line-height: 1.4;
	position: absolute;
	word-spacing: 0em;
	text-decoration: none;
	text-transform: none;
	width: 150px;
	z-index: 1000;
}
/* Position paragraphs */
p#first {
	top: 20px;
}
p#last {
	top: 50px;
}
</pre>
<p>Next I set up the JavaScript. I really didn&#8217;t need anything besides the one line of JavaScript at the top of this post, but I wanted to add a few other fancy animations and hover effects. (You could do a lot of this w/ CSS animations/transitions, but that&#8217;s a topic for another post.)</p>
<pre class="brush: jscript; title: ; notranslate">$().ready(function()
{
    // Instantiate the tubular plugin to load the awesome moon video
    $('body').tubular('woTCsNNfYEE','video'); // where someYTid is the YouTube ID and wrapper is your containing DIV.

    // Fade the overlaid text after 5 seconds
    $('.fade').delay(5000).animate({
        opacity: .5
    }, 1000);

    // Add a hover effect to those same element that are faded above
    $('.fade').hover(function()
    // mousein
    {
        $(this).animate({opacity:1});},
    // mouseout
    function()
    {
        $(this).animate({opacity:.5});
    });
});</pre>
<p>That&#8217;s it. If you take a look at <a href="http://www.seanmccambridge.com/tubular/" onclick="pageTracker._trackPageview('/outgoing/www.seanmccambridge.com/tubular/?referer=');">Sean&#8217;s example</a>, there is more you an do to leverage SWFObject for controlling the video. Use cases for this plugin may be limited, but I can see lots of potential for neat page designs.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/" rel="bookmark" title="March 3, 2012">Fun With JQuery Tubular</a></li>
<li><a href="http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/" rel="bookmark" title="February 8, 2010">Introducing the Baseline Development WordPress Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/16/baseline-theme-version-1-0-1/" rel="bookmark" title="February 16, 2010">Baseline Theme Version 1.0.1</a></li>
<li><a href="http://anthonygthomas.com/2011/05/17/new-theme/" rel="bookmark" title="May 17, 2011">New Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/14/why-use-blueprint-and-the-960-grid-system-in-the-baseline-theme/" rel="bookmark" title="February 14, 2010">Why Use Blueprint and the 960 Grid System in the Baseline Theme?</a></li>
</ul>
<p><!-- Similar Posts took 4.413 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Site</title>
		<link>http://anthonygthomas.com/2012/02/28/one-site/</link>
		<comments>http://anthonygthomas.com/2012/02/28/one-site/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 03:23:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=665</guid>
		<description><![CDATA[I just did a little adjusting to this WordPress theme so that the site should render well on all devices now. It looked pretty good before on smartphones before, but I was employing some mobile detection to load some different styles and only render the sidebar for desktop browsers. The main problem with this was [...]]]></description>
			<content:encoded><![CDATA[<p>I just did a little adjusting to this WordPress theme so that the site should render well on all devices now. It looked pretty good before on smartphones before, but I was employing some mobile detection to load some different styles and only render the sidebar for desktop browsers.</p>
<p>The main problem with this was that it messed with my cache. If a mobile browser visited the site, the mobile version was cached and served until the cache expired.</p>
<p>With a little more experience under my belt, it was incredibly simple to handle layout changes with media queries instead. In fact, it&#8217;s much simpler than the method I used before.<span id="more-665"></span></p>
<p>Admittedly, my layout is fairly simple. There are only a few images to deal with. Almost everything is done w/ CSS. So, all I really wanted to do was get rid of my floats on small screens. First I took the &#8220;mobile first&#8221; approach and got rid of my floats by default. Then I decided it would render well enough on a tablet at 768 pixels wide, so I set that as my cut-off.</p>
<pre class="brush: css; title: ; notranslate">@media only screen and (min-width : 768px) {
   section#content {
       float: left;
       width: 73%;
   }
   aside {
       clear: none;
       float: left;
       width: 20%;
   }
}</pre>
<p>The media query above displays the category navigation (which I have in an <code>aside</code> element) to the right. Anything smaller and the categories display underneath the list of blog posts.</p>
<p>This is a very simple example, but it gives you an idea of how easy it can be to make your design responsive.</p>
<p>The other bit I added was this:</p>
<pre class="brush: xml; title: ; notranslate">&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;</pre>
<p>This essentially tells high pixel-density devices to render the content like their normal pixel-density counterparts. This meta declaration has been of some interest to me lately. It dates back to 2007 and the first iPhone. You see, Steve Jobs made a decision for you. Steve Jobs decided that the iPhone should deliver a rich web experience like any other computer. So when a page loads in Mobile Safari, it&#8217;s scaled down and rendered at a functional width of 980 pixels. That means your page looks tiny <em>unless</em> you instruct it to scale up with the meta content above.</p>
<p>The end result is that adding one meta tag and ten lines of CSS turned my design into a responsive one.<br />
<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/02/28/one-site/" rel="bookmark" title="February 28, 2012">One Site</a></li>
<li><a href="http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/" rel="bookmark" title="February 16, 2012">Responsive Images: Keep It Simple; Keep It Small</a></li>
<li><a href="http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/" rel="bookmark" title="April 22, 2012">Media Queries for High Pixel-density Devices</a></li>
<li><a href="http://anthonygthomas.com/2008/12/16/when-using-a-grid-layout-css-framework-do-the-math/" rel="bookmark" title="December 16, 2008">When Using a Grid Layout CSS Framework, Do the Math</a></li>
<li><a href="http://anthonygthomas.com/2009/11/09/blueprint-taking-a-close-look-at-grid-css/" rel="bookmark" title="November 9, 2009">Blueprint: Taking a Close Look at grid.css</a></li>
</ul>
<p><!-- Similar Posts took 4.221 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/02/28/one-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Responsive Images: Keep It Simple; Keep It Small</title>
		<link>http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/</link>
		<comments>http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 01:58:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[responsive design]]></category>
		<category><![CDATA[responsive images]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=630</guid>
		<description><![CDATA[There&#8217;s a lot of excitement about responsive design in the mobile web development world. One of the techniques used in responsive design is responsive or adaptive images. There are a handful of techniques out there including CSS fluid images, using overflow:hidden to crop images and using a combination of .htaccess settings and PHP to deliver [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a lot of excitement about responsive design in the mobile web development world. One of the techniques used in responsive design is responsive or adaptive images. There are a handful of techniques out there including CSS fluid images, using <a href="http://demo.solemone.de/overflow-image-with-vertical-centering-for-responsive-web-design/" onclick="pageTracker._trackPageview('/outgoing/demo.solemone.de/overflow-image-with-vertical-centering-for-responsive-web-design/?referer=');">overflow:hidden to crop images</a> and using <a href="http://adaptive-images.com/" onclick="pageTracker._trackPageview('/outgoing/adaptive-images.com/?referer=');">a combination of .htaccess settings and PHP to deliver device-specific images</a>.</p>
<p>The first two solutions are fairly simple, but ignore one problem: serving a larger-than-necessary image over a potentially slow network to a user who may have limitations on the amount of data they can receive. Keeping website size down is also important now because <a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html" onclick="pageTracker._trackPageview('/outgoing/googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html?referer=');">Google is using site speed as a&nbsp;criterion&nbsp;for search rankings</a>. So, while I find the first two solutions interesting, I don&#8217;t think they&#8217;re the best we can do.<span id="more-630"></span></p>
<p>The adaptive image technique of routing image requests with a cookie and some Apache settings in an .htaccess file is also interesting. It too has limitations. First, it&#8217;s not for the faint of heart. If you don&#8217;t know your way around Apache directives, it might not be for you. It also relies on a PHP file. If you&#8217;re not using PHP, you&#8217;re out of luck. I&#8217;m no Apache expert, but I have some experience redirecting requests using .htaccess. Setup for adaptive images proved difficult because:</p>
<ol>
<li>I found it hard to incorporate the .htaccess settings alongside our other Apache directives that already exist.</li>
<li>I only needed responsive images for part of the site</li>
</ol>
<p>I freely admit that those limitations are mine and not anything fundamentally wrong with the method. If I were better with regular expressions, I probably could have gotten it going.</p>
<p>There is one limitation that is not taken into account: screen pixel density. A handful of Android phones have high resolution displays that defy how we typically understand pixels. The true resolution of the screen is 480 X 854 in this instance. Same for the iPhone 4. It has a pixel resolution of 640 X 960. No problem, right? Things get complicated when we use this meta tag:</p>
<pre class="brush: xml; title: ; notranslate">&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0&quot;/&gt;</pre>
<p>That meta tag is extremely useful because it forces those high density screens to render text much like their normal-density counterparts. In practical terms, if the above meta tag is in the head of your web page, an iPhone 4 will report a resolution of 320 X 480 and render text accordingly&#8211;making it more readable.</p>
<p>Life is great at this point because without that meta information, text will render much differently on a handful of high pixel-density phones.</p>
<p>We run into problems when we need to get accurate pixel counts of the device in question. Now that I&#8217;ve got consistently readable text on a wide variety of devices, I suddenly have wildly inaccurate information on pixels that are relevant to rendering images. Now when I call:</p>
<pre class="brush: jscript; title: ; notranslate">h = screen.height;</pre>
<p>An iPhone 4 will tell me that the screen height is 480 pixels when, for the purpose of rendering images, it&#8217;s actually 960 pixels. No big deal, but if I&#8217;m using JavaScript to determine the screen size so I can load an appropriately sized image, it&#8217;s going to load one that&#8217;s designed for a 480 pixel-width screen and it&#8217;s going to look terrible if the user switches to landscape mode.</p>
<p>Worse yet, while the iPhone 4 has a pixel density of 2, the Motorola Droid has a pixel density of 1.5. We <em>could</em> do some user agent sniffing to accomodate this, but the mobile device market changes so rapidly it would be nearly impossible to keep up with. Web standards tell us to look for supported features, not specific devices. So no user agent sniffing.</p>
<p>Luckily WebKit offers an imperfect solution that just happens to work in all the high pixel-density devices I&#8217;m aware of as of now:</p>
<pre class="brush: jscript; title: ; notranslate">window.devicePixelRatio</pre>
<p>Now we can get the true number of pixels like so:</p>
<pre class="brush: jscript; title: ; notranslate">// Set the default directory to 320
	&quot;use strict&quot;;
	d = 320;

	// Get the screen height
	h = screen.height;

	// set the height for non webkit browsers
	height = h;

	// Get the pixel ratio
	r = window.devicePixelRatio;

	// if devicePixelRatio is supported, calculate the device height
	if (typeof r !== 'undefined')
	{
		// Calculate the true number of pixels on the screen
		height = h * r;
	}</pre>
<p>My technique is to save images at several common device heights (because height becomes width in landscape mode) and write the image tag using JavaScript, so the device gets the smallest possible image that will still look good on the screen. The full script looks like so:</p>
<pre class="brush: jscript; title: ; notranslate">/****
 * Loads different header images based on the device height and pixel density (for webkit browsers)
 * Height is used because at any time, the device could potentially be turned to landscape mode
 */

/**
 * @var string
 * vars for directory (d), height (h), pixel ratio (r) and height
 */
var d, h, r, height;

/*
* Bind these to pagecreate so they work with JQuery Mobile's automagic AJAX page loads
*/
$('#page-id').live('pagecreate', function(event)
{
	// Set the default directory to 320
	&quot;use strict&quot;;
	d = 320;

	// Get the screen height
	h = screen.height;

	// set the height for non webkit browsers
	height = h;

	// Get the pixel ratio
	r = window.devicePixelRatio;

	if (typeof r !== 'undefined')
	{
		// Calculate the true number of pixels on the screen
		height = h * r;
	}

	// Set the image directory accordingly
	if (height &lt;= 320)
	{
		// load 320 header
		d = 320;
	}
	// Probably the most common height for current smartphones
	else if (height &lt;= 480)
	{
		// load 480 header
		d = 480;
	}
	// Many Motorola &amp; HTC devices have an 800-pixel height
	else if (height &lt;= 800)
	{
		// load 800 header
		d = 800;
	}
	// iPhone 4 &amp; Droid
	else if (height &gt; 800)
	{
		// load 960 header
		d = 960;
	}

	$('a#header-home-link').html('&lt;img src=&quot;/images/mobile/' + d + '/header.png&quot; alt=&quot;This is alt text.&quot; id=&quot;logo&quot; class=&quot;logos&quot; /&gt;');
});</pre>
<p>When the page loads, <code>#header-home-link</code> is just a normal HTML link with no image tag at all, so no image is loaded until we&#8217;ve determined the device screen size and write in the image tag with JavaScript (JQuery).</p>
<p>This technique will only work on WebKit browsers since other browsers don&#8217;t support <code>devicePixelRatio</code> at this time. Fortunately, this falls firmly within progressive enhancement. It&#8217;s not ideal if another mobile browser loads a pixelated image, but it has no effect on how the page itself functions.</p>
<p>Aside: You may have noticed that this is all bound to a &#8216;pagecreate&#8217; event instead of the normal <code>ready()</code> method in JQuery. <a href="http://jquerymobile.com/test/docs/api/events.html" onclick="pageTracker._trackPageview('/outgoing/jquerymobile.com/test/docs/api/events.html?referer=');">That&#8217;s because I&#8217;m using JQuery Mobile in this instance</a>.</p>
<p>So there you have it. Detecting screen dimensions in pixels is fairly easy, but you do need to account for pixel density. While this approach is not perfect, it works well in most devices and as of now, no standard way of serving responsive images has emerged. This is as good as anything I&#8217;ve found.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/" rel="bookmark" title="February 16, 2012">Responsive Images: Keep It Simple; Keep It Small</a></li>
<li><a href="http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/" rel="bookmark" title="April 22, 2012">Media Queries for High Pixel-density Devices</a></li>
<li><a href="http://anthonygthomas.com/2012/02/28/one-site/" rel="bookmark" title="February 28, 2012">One Site</a></li>
<li><a href="http://anthonygthomas.com/2008/12/16/when-using-a-grid-layout-css-framework-do-the-math/" rel="bookmark" title="December 16, 2008">When Using a Grid Layout CSS Framework, Do the Math</a></li>
<li><a href="http://anthonygthomas.com/2008/04/11/transparency/" rel="bookmark" title="April 11, 2008">Transparency</a></li>
</ul>
<p><!-- Similar Posts took 4.613 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Substratum: Tiny, Semantic CSS Framework for Creating Columns</title>
		<link>http://anthonygthomas.com/2011/10/25/substratum-tiny-semantic-css-framework-for-creating-columns/</link>
		<comments>http://anthonygthomas.com/2011/10/25/substratum-tiny-semantic-css-framework-for-creating-columns/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 02:28:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[Substratum]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=605</guid>
		<description><![CDATA[I wrote about this a while back, but I thought I&#8217;d make it official since I&#8217;ve used it on the last few projects I&#8217;ve worked on. I&#8217;ve named my mini CSS framework for creating columns and put it in a Mercurial repository. It&#8217;s very small (412 kb minified), semantic and aims to stay out of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://anthonygthomas.com/2011/04/18/css-scaffolding/">I wrote about this a while back</a>, but I thought I&#8217;d make it official since I&#8217;ve used it on the last few projects I&#8217;ve worked on. I&#8217;ve <a href="https://bitbucket.org/truetone/substratum" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/truetone/substratum?referer=');">named my mini CSS framework for creating columns and put it in a Mercurial repository</a>. It&#8217;s very small (412 kb minified), semantic and aims to stay out of the way. It also needs some thorough browser testing. Have at it folks.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2011/10/25/substratum-tiny-semantic-css-framework-for-creating-columns/" rel="bookmark" title="October 25, 2011">Substratum: Tiny, Semantic CSS Framework for Creating Columns</a></li>
<li><a href="http://anthonygthomas.com/2011/04/18/css-scaffolding/" rel="bookmark" title="April 18, 2011">CSS Scaffolding</a></li>
<li><a href="http://anthonygthomas.com/2008/12/16/when-using-a-grid-layout-css-framework-do-the-math/" rel="bookmark" title="December 16, 2008">When Using a Grid Layout CSS Framework, Do the Math</a></li>
<li><a href="http://anthonygthomas.com/2009/11/09/blueprint-taking-a-close-look-at-grid-css/" rel="bookmark" title="November 9, 2009">Blueprint: Taking a Close Look at grid.css</a></li>
<li><a href="http://anthonygthomas.com/2008/11/22/blueprint-css-tutorial-file/" rel="bookmark" title="November 22, 2008">Blueprint CSS Tutorial File</a></li>
</ul>
<p><!-- Similar Posts took 4.147 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2011/10/25/substratum-tiny-semantic-css-framework-for-creating-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Theme</title>
		<link>http://anthonygthomas.com/2011/05/17/new-theme/</link>
		<comments>http://anthonygthomas.com/2011/05/17/new-theme/#comments</comments>
		<pubDate>Wed, 18 May 2011 02:51:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=580</guid>
		<description><![CDATA[I did a soft launch of my new WordPress theme last week. There are a few things I&#8217;d like to point out. First is the decision to go to HTML5. HTML5 (combined with the HTML5 Shiv) actually made writing the styles quite a bit simpler. It&#8217;s a bit of adjustment after writing XHTML for so [...]]]></description>
			<content:encoded><![CDATA[<p>I did a soft launch of my new WordPress theme last week. There are a few things I&#8217;d like to point out. First is the decision to go to HTML5. HTML5 (<a href="http://code.google.com/p/html5shiv/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/html5shiv/?referer=');">combined with the HTML5 Shiv</a>) actually made writing the styles quite a bit simpler. It&#8217;s a bit of adjustment after writing XHTML for so long, but when it came time to write the styles the new tags <em>meant fewer ids and classes</em>. I found that very handy.</p>
<p>Also I&#8217;m using less JavaScript than I was before. Instead the hover effects are accomplished using CSS3 transitions.<span id="more-580"></span></p>
<p>For instance, here is the CSS for the hover effect on the sidebar nav:</p>
<pre class="brush: css; title: ; notranslate">-webkit-transition-property: background, margin-left;
-webkit-transition-duration: 0.5s, 0.5s;
-webkit-transition-timing-function: linear, ease-in;
-moz-transition-property: background margin-left;
-moz-transition-duration: 0.5s, 0.5s;
-moz-transition-timing-function: linear, ease-in;
-o-transition-property: background margin-left;
-o-transition-duration: 0.5s, 0.5s;
-o-transition-timing-function: linear, ease-in;
transition-property: background margin-left;
transition-duration: 0.5s, 0.5s;
transition-timing-function: linear, ease-in;</pre>
<p>Then I simply redefine the background, right and left margins for the hover state:</p>
<pre class="brush: css; title: ; notranslate">background: #0D7B15;
margin-left: -1em;</pre>
<p>The browser then just takes 0.5 seconds to transition from the default state to the hover state.</p>
<p>I also added some other transitions as well. For instance, you can delay when the transition starts. See if you can spot this one:</p>
<pre class="brush: css; title: ; notranslate">-webkit-transition-property: top, left;
-webkit-transition-duration: 5s, 5s;
-webkit-transition-timing-function: linear, linear;
-webkit-transition-delay: 32s, 32s;
-moz-transition-property: top, left;
-moz-transition-delay: 32s, 32s;
-moz-transition-duration: 5s, 5s;
-moz-transition-timing-function: linear, linear;transition-property: top, left;
transition-duration: 5s, 5s;
transition-delay: 32s, 32s;
transition-timing-function: linear, ease-in-out;</pre>
<p>This effect is attached to an &#8216;animate&#8217; class that is triggered by JQuery when the page loads. There&#8217;s a 32 second delay and then the transition between states begins. It&#8217;s pretty fun stuff.</p>
<p>Caveat: <a href="http://caniuse.com/#search=transitions" onclick="pageTracker._trackPageview('/outgoing/caniuse.com/_search=transitions?referer=');">Transitions are only supported in Firefox 4+, but they&#8217;ve been supported in WebKit browsers for a long time. Internet Explorer will not support them until version 10</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2011/05/17/new-theme/" rel="bookmark" title="May 17, 2011">New Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/03/20/no-flash-required/" rel="bookmark" title="March 20, 2010">No Flash Required</a></li>
<li><a href="http://anthonygthomas.com/2012/03/09/using-impress-js/" rel="bookmark" title="March 9, 2012">Using Impress.js</a></li>
<li><a href="http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/" rel="bookmark" title="March 3, 2012">Fun With JQuery Tubular</a></li>
<li><a href="http://anthonygthomas.com/2009/11/09/blueprint-taking-a-close-look-at-grid-css/" rel="bookmark" title="November 9, 2009">Blueprint: Taking a Close Look at grid.css</a></li>
</ul>
<p><!-- Similar Posts took 4.152 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2011/05/17/new-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Scaffolding</title>
		<link>http://anthonygthomas.com/2011/04/18/css-scaffolding/</link>
		<comments>http://anthonygthomas.com/2011/04/18/css-scaffolding/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 00:12:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=533</guid>
		<description><![CDATA[Last week I gave a talk at MinneWebCon along with Ken Loomis and Ethan Poole. My section of the talk dealt with the CSS we use at work. One of the main problems I&#8217;ve come to have with using CSS frameworks is that they put presentation back into the markup. Every CSS framework I&#8217;ve seen [...]]]></description>
			<content:encoded><![CDATA[<p>Last week <a href="http://www.slideshare.net/kmloomis/minne-webcon-2011v5" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/kmloomis/minne-webcon-2011v5?referer=');">I gave a talk</a> at <a href="http://minnewebcon.umn.edu" onclick="pageTracker._trackPageview('/outgoing/minnewebcon.umn.edu?referer=');">MinneWebCon</a> along with Ken Loomis and <a href="http://ethanpoole.com/" onclick="pageTracker._trackPageview('/outgoing/ethanpoole.com/?referer=');">Ethan Poole</a>. My section of the talk dealt with <a href="http://sua.umn.edu/_web/css-styleguide.php" onclick="pageTracker._trackPageview('/outgoing/sua.umn.edu/_web/css-styleguide.php?referer=');">the CSS we use at work</a>. One of the main problems I&#8217;ve come to have with using CSS frameworks is that they put presentation back into the markup. Every CSS framework I&#8217;ve seen has classes like these:</p>
<ul>
<li>ez-50 (ez-css)</li>
<li>container_12 (960GS)</li>
<li>grid_1 (960GS)</li>
<li>span-4 (Blueprint)</li>
</ul>
<p>After years of adopting standards that keep presentation separate from the markup, frameworks like these (<a href="http://www.testking.com/techking/roundups/27-great-css-frameworks-you-must-check-out/" onclick="pageTracker._trackPageview('/outgoing/www.testking.com/techking/roundups/27-great-css-frameworks-you-must-check-out/?referer=');">and others</a>) put it right back into the code. Not only is that a bad practice, but it removes one of the chief benefits of CSS: the ability to change your presentation without touching the markup.</p>
<p>The most common problem these frameworks solve is laying out columns. So I came up with a handful of CSS classes that solve the same problem, but do so in a way that will allow you to alter the appearance of the pages <em>without altering the markup</em>.</p>
<p>These classes are applicable in a general way (i.e., within the content), so it&#8217;s useful to keep them named as they are for that purpose. You can also copy these same styles to your ids to get the desired widths and column layout.Â I encourage you to write these styles into page ids whenever possible as that will make your page markup more semantic. You should think of these classes more like scaffolding than a framework. You can get started quickly, then modify them to meet your needs.Â <a href="http://anthonygthomas.com/wp-content/uploads/2011/04/framework.css.zip">The minified file is only 412 bytes</a>.<span id="more-533"></span></p>
<pre class="brush: css; title: ; notranslate">/* anthonygthomas.com/
   v1.0 | 20110417
   License: none (public domain)
*/

/******

 # Table of Contents #

## Define columns
### Last column
## Narrow column
### Last narrow column
## Wide column
## First column
## Column clearfix

 *******/

/* Define columns */
/* apply this to any block element */
.column {
    display: inline-block;
    float:left;
    margin-right: 2%;
    width: 48%;
}
    /* Last column */
    /* apply this to the last column */
    .column.last {
	margin-left: 2%;
	margin-right: 0;
	width: 48%;
    }

/* Narrow column */
.column.narrow {
    margin-right: 5%;
    width: 30%;
}
    /* Last narrow column */
    .column.narrow.last {
	margin-left: 0;
	margin-right: 0;
    }

/* Wide column */
.column.wide {
    margin-right: 4%;
    width: 66%;
}

/* First column */
.first {
    clear:left;
}

/* Column clearfix */
/* perishablepress.com/press/2009/12/06/new-clearfix-hack/ */
.column:after {
	visibility: hidden;
	display: block;
	font-size: 0;
	content: &quot; &quot;;
	clear: both;
	height: 0;
	}
* html .column             { zoom: 1; } /* IE6 */
*:first-child+html .column { zoom: 1; } /* IE7 */</pre>
<p><a href="http://anthonygthomas.com/examples/test.html">Here is a demo page</a>.</p>
<h3>The Classes</h3>
<h4>The column Class</h4>
<pre class="brush: css; title: ; notranslate">/* apply this to any block element */
.column {
    display: inline-block;
    float:left;
    margin-right: 2%;
    width: 48%;
}</pre>
<p>This creates a 50% column for any block element. By default columns float left, so the next consecutive element with the same class will end up on the right side of the preceding element. To get rid of the 2% margin in the right column and add a 2% gutter to the left of the second column (for a total of a 4% gutter) use the <code>.last</code> class:</p>
<pre class="brush: css; title: ; notranslate">/* apply this to the last column */
    .column.last {
	margin-left: 2%;
	margin-right: 0;
	width: 48%;
    }</pre>
<h4>The narrow Class (three columns)</h4>
<p>This creates a 30% width column with a 5% right margin. To make the third column work correctly, you need to add a <code>last</code> class.</p>
<pre class="brush: css; title: ; notranslate">/* Narrow column */
.column.narrow {
    margin-right: 5%;
    width: 30%;
}
    /* Last narrow column */
    .column.narrow.last {
	margin-left: 0;
	margin-right: 0;
    }</pre>
<h4>The wide Class</h4>
<pre class="brush: css; title: ; notranslate">/* Wide column */
.column.wide {
    margin-right: 4%;
    width: 66%;
}</pre>
<h4>The first Class</h4>
<pre class="brush: css; title: ; notranslate">/* First column */
.first {
    clear:left;
}</pre>
<p>Apply this to the first column to force the element to wrap below it&#8217;s preceding element.</p>
<h4>The clearfix</h4>
<p>This is a common &#8220;clearfix&#8221; method. You can find variations on this all over the web. <a href="http://perishablepress.com/press/2009/12/06/new-clearfix-hack/" onclick="pageTracker._trackPageview('/outgoing/perishablepress.com/press/2009/12/06/new-clearfix-hack/?referer=');">This one is from Perisable Press</a>. Rather than selectively apply the class, I wrote into a class that I knew needed clearing.</p>
<pre class="brush: css; title: ; notranslate">/* Column clearfix */
/* perishablepress.com/press/2009/12/06/new-clearfix-hack/ */
.column:after {
	visibility: hidden;
	display: block;
	font-size: 0;
	content: &quot; &quot;;
	clear: both;
	height: 0;
	}
* html .column             { zoom: 1; } /* IE6 */
*:first-child+html .column { zoom: 1; } /* IE7 */</pre>
<p>This is not a completely tested framework. I make no guarantees that it will work in all old browsers.</p>
<p>The thing I encourage you to take away is that CSS frameworks&#8211;if used as-is&#8211;are not semantic. It&#8217;s not hard to come up with your own, more semantic framework. Instead of thinking of these as grid systems, you should think of them as scaffolding. This is a good place to start. Take it from here and modify it to fit your own needs.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2011/04/18/css-scaffolding/" rel="bookmark" title="April 18, 2011">CSS Scaffolding</a></li>
<li><a href="http://anthonygthomas.com/2009/11/09/blueprint-taking-a-close-look-at-grid-css/" rel="bookmark" title="November 9, 2009">Blueprint: Taking a Close Look at grid.css</a></li>
<li><a href="http://anthonygthomas.com/2008/12/16/when-using-a-grid-layout-css-framework-do-the-math/" rel="bookmark" title="December 16, 2008">When Using a Grid Layout CSS Framework, Do the Math</a></li>
<li><a href="http://anthonygthomas.com/2008/11/22/blueprint-css-tutorial-file/" rel="bookmark" title="November 22, 2008">Blueprint CSS Tutorial File</a></li>
<li><a href="http://anthonygthomas.com/2011/05/17/new-theme/" rel="bookmark" title="May 17, 2011">New Theme</a></li>
</ul>
<p><!-- Similar Posts took 4.551 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2011/04/18/css-scaffolding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Document Structure</title>
		<link>http://anthonygthomas.com/2011/04/17/html5-document-structure/</link>
		<comments>http://anthonygthomas.com/2011/04/17/html5-document-structure/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 17:42:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=515</guid>
		<description><![CDATA[Since I&#8217;ve started working with HTML5 Â a bit, I&#8217;ve had to adjust my thinking about page structure. HTML 5 page structure differs from HTML 4 or XHTML significantly. (X)HTML document structure should look like this: This has changed in HTML5. HTML5 has &#8220;outlining elements&#8221; that essentially reset the page hierarchy. This is a little tough [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve started working with HTML5 Â a bit, I&#8217;ve had to adjust my thinking about page structure. HTML 5 page structure differs from HTML 4 or XHTML <em>significantly</em>. (X)HTML document structure should look like this:<span id="more-515"></span></p>
<div id="attachment_518" class="wp-caption aligncenter" style="width: 283px"><a href="http://cssglobe.com/post/1213/how-to-use-headings-in-html" onclick="pageTracker._trackPageview('/outgoing/cssglobe.com/post/1213/how-to-use-headings-in-html?referer=');"><img class="size-medium wp-image-518 " title="Proper Use of Headings in HTML 4 &amp; XHTML" src="http://anthonygthomas.com/wp-content/uploads/2011/04/headings-273x300.gif" alt="html headings diagram" width="273" height="300" /></a><p class="wp-caption-text">Proper document structure in HTML 4 and XHTML. (http://cssglobe.com/post/1213/how-to-use-headings-in-html)</p></div>
<p>This has changed in HTML5. <a href="http://dev.opera.com/articles/view/new-structural-elements-in-html5/" onclick="pageTracker._trackPageview('/outgoing/dev.opera.com/articles/view/new-structural-elements-in-html5/?referer=');">HTML5 has &#8220;outlining elements&#8221; that essentially reset the page hierarchy</a>. This is a little tough to get your head around if you&#8217;ve spent as many years as I have using the page structure in the figure above. A diagram of an HTML5 document might look like this:</p>
<div id="attachment_521" class="wp-caption aligncenter" style="width: 283px"><img class="size-full wp-image-521" title="HTML5 Document Structure" src="http://anthonygthomas.com/wp-content/uploads/2011/04/html5.png" alt="HTML5 Document Structure" width="273" height="300" /><p class="wp-caption-text">A demonstration of HTML5 &quot;sectioning&quot; elements.</p></div>
<p>Notice the difference? It&#8217;s fairly subtle, but most recognizable in the <code>section</code> element. In (X)HTML, the headings in the article section would be subject to the same hierarchy as the rest of the document so article headings would have to start with <code>h3</code> or maybe even <code>h4</code>. In HTML5, <code>nav</code>, <code>section</code>, <code>article</code> and <code>aside</code> are &#8220;sectioning&#8221; elements, so they can have their own hierarchy of headings. Notice that the <code>header</code> HTML5 tag is not a sectioning element, so it&#8217;s <code>h1</code> still rules the page.</p>
<p><strong>Note:</strong> No browsers support this outlining algorithm. (I know.) It&#8217;s coming, so I think it&#8217;s important to get our heads around it now.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2011/04/17/html5-document-structure/" rel="bookmark" title="April 17, 2011">HTML5 Document Structure</a></li>
<li><a href="http://anthonygthomas.com/2012/03/09/using-impress-js/" rel="bookmark" title="March 9, 2012">Using Impress.js</a></li>
<li><a href="http://anthonygthomas.com/2010/09/05/baseline-theme-version-1-1/" rel="bookmark" title="September 5, 2010">Baseline Theme Version 1.1</a></li>
<li><a href="http://anthonygthomas.com/2010/02/14/why-use-blueprint-and-the-960-grid-system-in-the-baseline-theme/" rel="bookmark" title="February 14, 2010">Why Use Blueprint and the 960 Grid System in the Baseline Theme?</a></li>
<li><a href="http://anthonygthomas.com/2008/11/22/blueprint-css-tutorial-file/" rel="bookmark" title="November 22, 2008">Blueprint CSS Tutorial File</a></li>
</ul>
<p><!-- Similar Posts took 4.187 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2011/04/17/html5-document-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple RSS Parsing and Caching Using PHP</title>
		<link>http://anthonygthomas.com/2011/03/12/simple-rss-parsing-and-caching-using-php/</link>
		<comments>http://anthonygthomas.com/2011/03/12/simple-rss-parsing-and-caching-using-php/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 02:23:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=481</guid>
		<description><![CDATA[I feel like I should begin by stating that my college degree is in English Literature. In other words, I am not formally trained to be a programmer. Still I&#8217;ve spent many years working in PHP. It can be liberating to find out that something you thought would be complicated, is actually not that hard [...]]]></description>
			<content:encoded><![CDATA[<p>I feel like I should begin by stating that my college degree is in English Literature. In other words, I am not formally trained to be a programmer. Still I&#8217;ve spent many years working in PHP. It can be liberating to find out that something you thought would be complicated, is actually not that hard when broken down into discrete steps.</p>
<p>This whole adventure started for me when I went looking for a way to parse an <acronym title="Really Simple Syndication">RSS</acronym> feed. Contrary to those who proclaim that <a href="http://www.google.com/search?sourceid=chrome&#038;ie=UTF-8&#038;q=rss+is+dead" onclick="pageTracker._trackPageview('/outgoing/www.google.com/search?sourceid=chrome_038_ie=UTF-8_038_q=rss+is+dead&amp;referer=');">RSS is dead</a>, at it&#8217;s heart, RSS is <acronym title="eXtenxible Markup Language">XML</acronym>. As such it&#8217;s a useful method to access content. In my case, I wanted to parse my blog RSS feed as well as my most recent <a href="http://twitter.com/truetone" onclick="pageTracker._trackPageview('/outgoing/twitter.com/truetone?referer=');">Tweets</a>. That was revelation number one.</p>
<blockquote><p>RSS is XML > XML has a structure that can be put into objects in PHP</p></blockquote>
<p>To many of my friends and colleagues, this may seem incredibly simple. To me it was a revelation that opened up a new door. I&#8217;ve never tried to create an RSS parser before. Suddenly it was less daunting. (Aside: For me, simple truths often come as revelations. To know me is to know this.)<br />
<span id="more-481"></span></p>
<h3>Parsing the RSS Feed</h3>
<p>It turns out that PHP 5 has some really handy tools for dealing with HTML and XML in the <a href="http://php.net/manual/en/class.domdocument.php" onclick="pageTracker._trackPageview('/outgoing/php.net/manual/en/class.domdocument.php?referer=');">DOMDocument</a> class.</p>
<p>First, we create an array to store the XML. Next instantiate <code>DOMDocument</code> and call the <code>load</code> function:</p>
<pre class="brush: php; title: ; notranslate">$doc = new DOMDocument();
$doc-&gt;load($url);</pre>
<p>Then it&#8217;s as simple as looping through the XML nodes and storing what you want in the <code>$xml</code> array. For this use <code>getElementsByTagName</code>:</p>
<pre class="brush: php; title: ; notranslate">foreach ($doc-&gt;getElementsByTagName('item') as $node)
{
    //do stuff
}</pre>
<p>In my case I knew the most I wanted was a simple list with title, description, link and date. Thus:</p>
<pre class="brush: php; title: ; notranslate">foreach ($doc-&gt;getElementsByTagName('item') as $node)
{
    $rss = array (
        'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue,
        'description' =&gt; $node-&gt;getElementsByTagName('description')-&gt;item(0)-&gt;nodeValue,
        'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue,
        'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue
        );
    }
}</pre>
<p>Now each loop loads the information I want into an array called <code>$rss</code>. Next just push that into the <code>$xml</code> array:</p>
<pre class="brush: php; title: ; notranslate">foreach ($doc-&gt;getElementsByTagName('item') as $node)
{
    $rss = array (
        'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue,
        'description' =&gt; $node-&gt;getElementsByTagName('description')-&gt;item(0)-&gt;nodeValue,
        'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue,
        'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue
        );
      array_push($xml, $rss);
    }
}</pre>
<p>Finally I serialized the data to store it in a cache file. So we end up with:</p>
<pre class="brush: php; title: ; notranslate">protected function getFeed($url)
{
    $xml = array();
    $doc = new DOMDocument();
    $doc-&gt;load($url);
    foreach ($doc-&gt;getElementsByTagName('item') as $node)
    {
      $rss = array (
        'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue,
        'description' =&gt; $node-&gt;getElementsByTagName('description')-&gt;item(0)-&gt;nodeValue,
        'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue,
        'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue
        );
      array_push($xml, $rss);
    } //endforeach element ids
    return serialize($xml);
  }
}</pre>
<p>So now we can deal with the RSS information. Next we just have to create a way to cache it so the feed isn&#8217;t unnecessarily pulled in over and over. This is when another liberating revelation came my way. I began to look for methods of caching and I saw the following advice on a forum:</p>
<blockquote><p>Get the feed. Write it to a text file. For each new request, check the mod time of the text file. It enough time has passed, update the file.</p></blockquote>
<p>There are probably more complex caching algorithms than this, but it seemed like a good place to start. So I wrote a caching function. It takes an array with two parameters. The name of the service as the array key and the url of the RSS feed. First we check to see if a cache file exists, and if it does, we check to see whether or not it has expired. I chose an arbitrary span of 60 seconds for my cache file:</p>
<pre class="brush: php; title: ; notranslate">public function checkCache($data=array())
{
    foreach ($data as $service =&gt; $feed)
    {
      $path = '/tmp/' . $service . '.cache';
      if ((!file_exists($path) || time() - filemtime($path) &gt; 60) &amp;&amp; $cache = fopen($path, 'w+'))
      {
           // do stuff
      }
    }
}</pre>
<p>So if there is no file, or the requisite time has expired and the file can be opened we call the aforementioned <code>getFeed</code> function to get the feed data, write it to the file and send it to the webpage:</p>
<pre class="brush: php; title: ; notranslate">$rss_contents = $this-&gt;getFeed($feed);
fwrite($cache, $rss_contents);
fclose($cache);
return unserialize($rss_contents);</pre>
<p>If the cache doesn&#8217;t need to be updated, we simply read it and send the data that way:</p>
<pre class="brush: php; title: ; notranslate">$cache = fopen($path, 'r');
return unserialize(file_get_contents($path)); // remember to unserialize since we serialized it initially
fclose($cache);</pre>
<p>The whole function looks like this:</p>
<pre class="brush: php; title: ; notranslate">public function checkCache($data=array())
{
  foreach ($data as $service =&gt; $feed)
  {
    $path = '/tmp/' . $service . '.cache';
    if ((!file_exists($path) || time() - filemtime($path) &gt; 60) &amp;&amp; $cache = fopen($path, 'w+'))
    {
      $rss_contents = $this-&gt;getFeed($feed);
      fwrite($cache, $rss_contents);
      fclose($cache);
      return unserialize($rss_contents);
    }
    else
    {
      $cache = fopen($path, 'r');
      return unserialize(file_get_contents($path));
      fclose($cache);
    }
  }
}</pre>
<p>The entire class together looks like this:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
class RssParser
{
  public function checkCache($data=array())
  {
    foreach ($data as $service =&gt; $feed)
    {
      $path = '/tmp/' . $service . '.cache';
      if ((!file_exists($path) || time() - filemtime($path) &gt; 60) &amp;&amp; $cache = fopen($path, 'w+'))
      {
        $rss_contents = $this-&gt;getFeed($feed);
        fwrite($cache, $rss_contents);
        fclose($cache);
        return unserialize($rss_contents);
      }
      else
      {
        $cache = fopen($path, 'r');
        return unserialize(file_get_contents($path));
        fclose($cache);
      }
    }
  }

  protected function getFeed($url)
  {
    $xml = array();
    $doc = new DOMDocument();
    $doc-&gt;load($url);
    foreach ($doc-&gt;getElementsByTagName('item') as $node)
    {
      $rss = array (
        'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue,
        'description' =&gt; $node-&gt;getElementsByTagName('description')-&gt;item(0)-&gt;nodeValue,
        'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue,
        'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue
        );
      array_push($xml, $rss);
    } //endforeach element ids
    return serialize($xml);
  }
}</pre>
<p>Finally, we instantiate it in the page where we&#8217;re going to use it and loop through it:</p>
<pre class="brush: php; title: ; notranslate">&lt;?

include_once('/path/to/rss_parser.class.php'); // include the php file with the class

$parser = new RssParser(); // instantiate the class
$blog_feed = $parser-&gt;checkCache(array('blog' =&gt; 'http://yourdomain.com/feed/')); // load the RSS
?&gt;
&lt;ul&gt;
&lt;?
foreach ($blog_feed as $key =&gt; $items)
{
    if ($key &lt; 5): ?&gt;
	&lt;li&gt;&lt;a href=&quot;&lt;?= $items['link'] ?&gt;&quot;&gt;&lt;?= $items['title'] ?&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;?php
    endif;
} //endforeach
?&gt;
&lt;/ul&gt;</pre>
<p>Done!</p>
<h3>Caveats</h3>
<p>Depending on your server configuration, you may need to put the class in your public directory. If you need to do that, make sure you put it in a directory with &#8217;750&#8242; permissions.</p>
<p>Also, your PHP configuration may not allow you to open urls with <code>fopen</code>. In that case, I suggest you use the <a href="http://us2.php.net/manual/en/book.curl.php" onclick="pageTracker._trackPageview('/outgoing/us2.php.net/manual/en/book.curl.php?referer=');">cURL library</a>.</p>
<p>This is a very simple RSS parsing and caching engine, but it works and it&#8217;s a good start to working with PHP and XML.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2011/03/12/simple-rss-parsing-and-caching-using-php/" rel="bookmark" title="March 12, 2011">Simple RSS Parsing and Caching Using PHP</a></li>
<li><a href="http://anthonygthomas.com/2009/03/22/cakephp-console-acl-help-file/" rel="bookmark" title="March 22, 2009">CakePHP Console ACL Help File</a></li>
<li><a href="http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/" rel="bookmark" title="November 26, 2008">Getting Blueprint CSS &#038; JavaScript Libraries Into Your CakePHP Layout</a></li>
<li><a href="http://anthonygthomas.com/2010/05/24/an-unexpected-problem-with-cakephp-and-email-elements/" rel="bookmark" title="May 24, 2010">An Unexpected Problem with CakePHP and Email Elements</a></li>
<li><a href="http://anthonygthomas.com/2012/03/09/using-impress-js/" rel="bookmark" title="March 9, 2012">Using Impress.js</a></li>
</ul>
<p><!-- Similar Posts took 4.661 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2011/03/12/simple-rss-parsing-and-caching-using-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

