Category Archives: Development

Simple Responsive Web Design

Just completed my first pass at making my site http://greggrichter.com, ‘Responsive’. For those not familiar with the term, it simply means that I am optimizing my site to dynamically change it’s layout depending on the screen size and device type you are accessing it from.  So users who come to my site from a smart phone will see the site optimized for their device.  Where as someone accessing the site from a traditional PC with a screen size of say 1000px wide, will receive a different view of the site.  This is of course a different approach than redirecting users to a mobile specific version of the site like you might see when you go to The Seattle Times. In that method, users that access http://seattletimes.com from an iPhone will be redirected to http://mobile.seattletimes.com for a layout optimized for their device.  Two completely separate pages.  The Responsive method I’m implementing serves up the same page for all device and screen sizes and dynamically adjusts the content and layout as specified. *note, at the time of this blog post, I have not implemented the same responsiveness to this blog.  Let’s call that phase 2.

For this initial pass, I took a very simplified approach. First, I had no desire to completely change the existing fixed width layout and code for my site so I left it as is. Second, I then used media queries to present new layout’s for pixel width breakpoints that I determined through trial and error. For now, I am only targeting traditional smart phone width’s and tablets in portrait mode as the site as-is renders fine in landscape mode. I will at some point need to add in even more breakpoints as the small tablet devices like the Kindle Fire and soon to be released iPad mini, will introduce a new set of users.

If I were to create a site from scratch I would be using fluid grid layouts with images that scale and up and down.  But again, I am retrofitting my existing site and want a simple and effective approach.

My three layouts then are:

greggrichter.com on a standard laptopExisting. Which looks great on anything at least 911px wide.

 

 

 

 

Large tablet portrait. Let’s be honest and call it an iPad. Anything less than 910px wide, but greater than #3, which is…

 

 

 

 

 

greggrichter.com on an iphoneSmart phone. Which I have set at anything less than 595px wide as the break point but actually the content is only about 286px wide.  I just center it.  Soon I’ll put another breakpoint in at 300px and build a mini-tablet layout for the 300 – 595px range.

 

 

 

 

To implement this is extremely simple. For each one of the breakpoints listed above, I added a media query to the end of my style sheet in the following format:

@media screen and (max-width: 910px){}

Within the two {} brackets, I grab my already established elements, id’s, classes, etc and apply new style rules to them. Only screens with a width of less than what I specify will render it.

Order matters here, so do these in order from top to bottom with biggest screen size at the top and smallest at the bottom.

For my smart phone view, I actually removed quite a bit of content like an image slideshow and other items and simply achieved this by using the CSS style ‘display:none’ on elements I didn’t want to be shown. Word of warning, just because you are using ‘display:none’ doesn’t mean you aren’t still downloading the entire page contents to the device… you are. I can get away with this on my site because I kept it extremely light to begin with.

You’ll also need to be sure and add a meta viewport tag to your header as follows:

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″ />

If you want to get in deep with Responsive Web Design, then buy this book.

Also, here is a great article in Wikipedia on RWD, http://en.wikipedia.org/wiki/Responsive_Web_Design.

And here is a link to my sites stylesheet. Scroll to the bottom to see the media query pieces. http://greggrichter.com/css/gsr.css

Lastly, if you want to see RWD in action, load my main page, http://greggrichter.com from a browser on your laptop or desktop and then resize the browser from biggest to smallest, and watch the content change dynamically.

Age Verification Script and Tutorial

Elysian Brewing Age Verification Page

Elysian Brewing Age Verification Page

*7/27/2013 UPDATE – I have received so many inquiries and questions on this topic that I’ve decided to turn this in to a service that I offer.  Please go to http://age-verify.com for complete details.

Currently I am in the midst of a fair amount of work for Elysian Brewing. The most recent piece in place is an age verification script that is a simple yes / no question to the user which sets a session cookie and then directs them accordingly. Sounds simple right? Well, not as simple as you might think.

Considerations and Requirements

  1. This is a pretty big site and changing the site root index.html page to be the actual verification page would mean the undoing of established search engine results and crawl data.
  2. Even if I did use the site root page for age verification, every page on the site (not to mention external links), would need to have the link back to root updated with a new location if the page extension were to change.
  3. I want to prompt for the age verification regardless of what page the site visitor first gets to.  They may not necessarily come in at the site root, but rather from a blog posting, searching for a brewery location, beer profile page, etc.
  4. I only want users to be prompted once per site visit, but not every time they navigate to a different page within the site.
  5. To accomplish #3 and #4, I’ll need to set a session cookie with a server side language such as PHP.
  6. I don’t want to change any of my page extensions from .html to .php for the same reason listed above in item #2.

Check out the Elysian Brewing website to see this live and in action. Elysian Brewing

Gregg