Create a Sidebar that Sticks Within an Element

You’ve probably seen this trick used before with social icons or a sidebar that sticks to the top of your screen as you scroll down the page.

The problem is that often they don’t stop scrolling and up either disappearing behind another element or overlapping something they shouldn’t, which looks cheap and unprofessional.

In this tutorial we’ll create a ‘sticky element’ that only scrolls until the maximum height of it’s parent element which will prevent that unsightly overflow.

Let’s start with a very basic html structure:

<style>
  body{
    border: 0;
    margin: 0 auto;
    padding: 0;
    width: 960px;
  }
  #header{
    background: #faa;
    height: 600px;
  }
  #footer{
    background: #aaf;
    height: 1000px;
  }
  #main{
    background: #afa;
    height: 1800px;
    position: relative;
  }
    #container{
       background: none repeat scroll 0 0 orange;
       height: 400px;
       position: absolute;
       right: 10px;
       top: 10px;
       width: 200px;
    }
</style>
<div id="header"></div>
<div id="main">
	<div id="container"></div>
</div>
<div id="footer"></div>

Sticky Sidebar

At this stage it leaves alot to the imagination in terms of design but it’s sufficient for the tutorial.

Our aim is to move the orange container down with the page, but to stop it before it collides with the purple container.

We’ll do this using, JQuery so be sure to include the jQuery script to your site.

jQuery(document).ready(function($){
  //customizable variables
  /* used too offset the window min and max for processing the scroll */
  var threshold_offset = 50; 
  /* the element to scroll */
  var $container = $("#container");
  /* the element's container (which its to scroll within) */
  var $main = $("#main"); 
  //leave these ones.
  var $window = $(window);  
  var window_min = 0;
  var window_max = 0;
});

The first step is to set up the basic JQuery structure and the initial variables:

The first step is to work out what the maximum and minimum scroll limits are for the orange container

i.e. how far can you scroll down or up before it has to stop.

Getting the minimum is easy, you just need to take it’s parent’s offset().top and add it to the elements CSS top.

The bottom is slightly more complex.

You need to take the parent’s offset top, add it to the parent’s height, then take away the container’s height and 2x the containers CSS top (to enable the padding in at the bottom too).

It looks like this:

Sticky Sidebar

/*
 set the container's maximum and minimum limits as well as movement thresholds
*/
function set_limits(){
  //max and min container movements
  var max_move = $main.offset().top + $main.height() - $container.height() - 2*parseInt($container.css("top") );
  var min_move = $main.offset().top;

  //save them
  $container.attr("data-min", min_move).attr("data-max",max_move);

  //window thresholds so the movement isn't called when its not needed!
  //you may wish to adjust the freshhold offset
  window_min = min_move - threshold_offset;
  window_max = max_move + $container.height() + threshold_offset;
}
//sets the limits for the first load
set_limits();

Now we have the limits set, we need to handle the page scroll.

It is a good idea to leave the scroll handling function to only run if the page is within a certain range, this is where we make use of the window_max, window_min and threshold_offset variables. The window_min requires the window to be scrolled down more than it’s value and window_max requires that the window not be scrolled down any futher than it’s value before the scroll event is even considered, this will hopefully reduce some of the load off the parser.

We need to bind the window’s scroll event to a function to check these limits:

function window_scroll(){
  //if the window is within the threshold, begin movements
  if( $window.scrollTop() >= window_min && $window.scrollTop() < window_max ){
    //window scroll is within range
    //reset the limits (optional)
    set_limits();
    //move the container
    container_move();
  }
}
$window.bind("scroll", window_scroll);

The actual moving of the container, as noted above, is done by our last function “container_move” which handles the last of the logic. This function will check to see exactly where the window is positioned in relation fo the container’s min and max amounts set in set_limits(), and then apply the appropriate margin to make the move.

/**
 * Handles moving the container if needed.
**/
function container_move(){
  var wst = $window.scrollTop();

  //if the window scroll is within the min and max (the container will be "sticky"
  if( wst >= $container.attr("data-min") && wst<= $container.attr("data-max") ){

    //work out the margin offset
    var margin_top = $window.scrollTop() - $container.attr("data-min");

    //margin it down!
    $container.css("margin-top", margin_top);

  //if the window scroll is below the minimum 
  }else if( wst <= $container.attr("data-min") ){

    //fix the container to the top.
    $container.css("margin-top",0);

  //if the window scroll is above the maximum 
  }else if( wst > $container.attr("data-max") ){

    //fix the container to the top
    $container.css("margin-top", $container.attr("data-max")-$container.attr("data-min")+"px" );

  }
}
//do one container move on page load
container_move();

Now if you put all the code together and preview your page, you should see an orange container that sits insider the green element all the way down the page until it is 10px away from the bottom of the purple container, at which point it sticks there.

A full working example of this tutorial can be found here: http://codepen.io/hitreach/pen/bLmrC

If you enjoyed this tutorial or would like any help please let me know in the comments below!

About the Author:

Chris Gilchrist is the MD & Founder of Hit Reach, a web design & SEO agency with it’s head offices in Dundee, Scotland. You can connect with Chris on Twitter and on .

Web Design Wednesday – 3 CSS3 Tutorials You can Use to Improve Your Website

There are different ways we can design and build a website. We’ve featured Parallax a couple of weeks ago, which was a great way of creating single page websites or even build an online portfolio. This time, we’ll be featuring three CSS3 tutorials ideal for improving or building an amazing website design.

Note: Just click on the image and you’ll be redirected to the tutorial page.

 

Circle Navigation Effect

 

 

The circle navigation effect provides a nice touch to your website’s hover buttons and image navigation. It’s an ideal feature that you can place on a photographer’s or graphic designer’s portfolio.

 

Draggable Image Boxes Grid

 

 

Another ideal feature that you can use on an image heavy website, the Draggable Image Boxes Grid tutorial allows you to create a web page that doesn’t need scroll bars for you to navigate along. Instead it allows you to use your mouse’s left click button and just drag away and navigate through your page.

 

Blur Menu

 

 

The blur menu tutorial allows you to add some character to your webpage – may it be an image heavy web page or a corporate website. The tutorial will provide you with different styles and applications for the blur menu effect.

 

There you have it – you can now start building your website or be creative and experiment more with the scripts provided by the tutorials. Enjoy using these CSS3 tutorials and let us know if you’ve built a website through the comments section!

 


 

You can follow us on FacebookTwitterGoogle Plus and Pinterest for more epic design news and inspiration! Also, don’t forget to subscribe to our blog for the latest design inspirations, stories, news and freebies.

If you’re looking out for free stuff you can check out freebies page and our free print templates page where you can download templates for calendars, brochures, business cards and more!  Stay awesome, fellas!

 

Read more posts by

Tutorial Tuesdays – How to Stop Procrastinating

Procrastination is a forever part of life. Like it or not it is here to stay with us whether you are a designer or not. If one thing, almost everybody is procrastinating in one way or another. Ironic as it may seem reading this post only shows that you are searching for ways on how to stop procrastinating while procrastinating.

 
In our efforts to find out ways on how to stop procrastinating, let us review some interesting facts about procrastination to further deepen our understanding about it. One fact is that there are about 20% of Americans who are admittedly chronic procrastinators. Other than that procrastinators are often the best liars especially with themselves. They often lie about the importance of task deeming it as unimportant and easy which makes it not too difficult for them to reason out why they are just going to do it the next day. Last interesting fact is that there are three types of procrastinators according to Joseph Ferrari Ph. D., one is the Arousal type, these are the type who get the rush when cramming on a task. Second are the Avoiders, these are the types who fear failing and would rather excuse themselves in doing a task. Lastly is the Decisional, they are the ones who cannot decide which task should be tackled first or how how will they tackle the task at hand.

In this edition of Tutorial Tuesdays, we will move a bit from the usual tutorial rundown to showcase to you guys some amazing and insightful videos that can help you combat procrastination and turn it around with these amazing videos.

How to Stop Procrastinating

 


 

Vik Nithy’s is one person that you should watch, apart from being able to start 3 companies before reaching the age of 21. In such a young age it is very interesting to hear what he has to say on why do people procrastinate and how to tackle procrastination.


 

AsapSCIENCE explains to us what procrastination and the science behind it. They also introduced the idea of using the Pomodoro technique in order to win over procrastination.


 

Funny and very thoughtful, Wellcast has made a tongue and cheek approach in procrastination. The video also talked about 3 simple but effective ways on how one can beat procrastination.


 

In this lengthy but thoughtful video, Stefan Molyneux offers some very interesting points on why do we procrastinate and tips on how to stop procrastinating.


 
Are you guys feeling ready to work after this post? Tell us what are your ways in dealing with procrastination and how you turn it around in the comments section below. Follow us out in FacebookTwitter, Pinterest and Google+ also do subscribe to get your latest dose of design news, tutorials and inspiration.

Looking for a library of high-quality print templates? The search is over! Hit the link and get high-quality print templates here for free!

Read more posts by

Tutorial Tuesdays – How to Stop Procrastinating

Procrastination is a forever part of life. Like it or not it is here to stay with us whether you are a designer or not. If one thing, almost everybody is procrastinating in one way or another. Ironic as it may seem reading this post only shows that you are searching for ways on how to stop procrastinating while procrastinating.

 
In our efforts to find out ways on how to stop procrastinating, let us review some interesting facts about procrastination to further deepen our understanding about it. One fact is that there are about 20% of Americans who are admittedly chronic procrastinators. Other than that procrastinators are often the best liars especially with themselves. They often lie about the importance of task deeming it as unimportant and easy which makes it not too difficult for them to reason out why they are just going to do it the next day. Last interesting fact is that there are three types of procrastinators according to Joseph Ferrari Ph. D., one is the Arousal type, these are the type who get the rush when cramming on a task. Second are the Avoiders, these are the types who fear failing and would rather excuse themselves in doing a task. Lastly is the Decisional, they are the ones who cannot decide which task should be tackled first or how how will they tackle the task at hand.

In this edition of Tutorial Tuesdays, we will move a bit from the usual tutorial rundown to showcase to you guys some amazing and insightful videos that can help you combat procrastination and turn it around with these amazing videos.

How to Stop Procrastinating

 


 

Vik Nithy’s is one person that you should watch, apart from being able to start 3 companies before reaching the age of 21. In such a young age it is very interesting to hear what he has to say on why do people procrastinate and how to tackle procrastination.


 

AsapSCIENCE explains to us what procrastination and the science behind it. They also introduced the idea of using the Pomodoro technique in order to win over procrastination.


 

Funny and very thoughtful, Wellcast has made a tongue and cheek approach in procrastination. The video also talked about 3 simple but effective ways on how one can beat procrastination.


 

In this lengthy but thoughtful video, Stefan Molyneux offers some very interesting points on why do we procrastinate and tips on how to stop procrastinating.


 
Are you guys feeling ready to work after this post? Tell us what are your ways in dealing with procrastination and how you turn it around in the comments section below. Follow us out in FacebookTwitter, Pinterest and Google+ also do subscribe to get your latest dose of design news, tutorials and inspiration.

Looking for a library of high-quality print templates? The search is over! Hit the link and get high-quality print templates here for free!

Read more posts by

Tutorial Tuesdays – Adobe InDesign Tutorials for Beginners

Adobe InDesign is considered to be one of the most amazing desktop publishing programs to this date. With  the last year’s release of InDesign CS6 designers are now given a faster, efficient and better tool to their advantage in creating amazing posters, brochures even book and magazine layouts . While Adobe InDesign may not have the bells and whistles of Adobe Photoshop and Illustrator it basically makes up with its publishing and print capabilities.

Adobe InDesign Tutorials

We have covered some of InDesign’s capabilities in the How To Make A Simple Music Festival Poster tutorial before and that is why for today we are listing down the best tutorials we found around the internet. Here are some of the best tutorials to help you guys in further understanding Adobe InDesign and it’s processes adding another arsenal in your creative toolbox.

To get things rolling let’s start off with:

Adobe InDesign Tutorials

10 Things Beginners Want To Know How To Do

Terry White demonstrates 10 things that beginners should know and how to do it in InDesign CS6.
 


 
Now that you guys have a fair understanding about Adobe InDesign and what it can do let us now get down to business.

Adobe InDesign Tutorials

1. Working with Tools

Get to know the various tools in Adobe InDesign with Kelly McCathran.
 


 
 

Adobe InDesign Tutorials

2. Mastering InDesign Preferences

Customizing InDesign’s preferences not only helps you to suit your need but it also helps in streamlining the work process.
 


 
 

Adobe InDesign Tutorials

3. Work with type in InDesign

While Photoshop and Illustrator are known for their image and graphic making capabilities, InDesign takes text formatting to a whole different level.
 


 
 

Adobe InDesign Tutorials

4.  Working with Frames

Everything in InDesign is in a frame, let it be a text or an image learning how to master frames is a must.
 


 
 

Adobe InDesign Tutorials

5.  Working with Graphics

Kelly McCarthran show us the ropes of  the basic know how in working with graphics and also teaching us how to work with different image formats.
 


 
 

SEE ALSO: 30 Awesome 2013 Movie Posters

 
 


 

Adobe InDesign Tutorials

6. Mastering the Page Tool

Multiple pages within a document is one of InDesign’s arsenal. Neshantheny Kumana teaches us how to manipulate, create folds and adding a spine using a fake magazine layout.
 


 
 

Adobe InDesign Tutorials

7.  Alignment in InDesign CS6

Hasten your workflow by mastering the alignment tool with Jeff Witchel.
 


 
 

Adobe InDesign Tutorials

8.  Clipping Paths with InDesign CS6

Joe Luxton shows us how to work on and manipulate clipping paths without breaking a sweat.
 


 
 

Adobe InDesign Tutorials

9.  Understanding Liquid Layouts

Liquid Layouts is one of InDesign CS6′s newest feature. This tutorial shows us a brief tour of the said new feature.
 


 
 

Adobe InDesign Tutorials

10.  Using Glyphs in making a Typographic Poster

Jo Guilliver showcase us how to use glyphs in making an amazing typographic poster.
 


 
 

Adobe InDesign Tutorials

11. Make a Grid Based CV in InDesign

Using a grid system in your layout does not only make your design aesthetically pleasing but it also helps speeding up the work process.
 


 
 
Special Mentions:
Adobe InDesign CS6 Tutorial
Adobe InDesign Tips I Wish I’d Known When Starting Out 
 


We hope that you guys enjoy this humble list of tutorials that we have for you guys and be sure to drop some comments below if you have anything in mind and would like to share it to us. If you are a seasoned InDesign user looking for a library of print templates look no further! We have a huge collection of print templates here and it is absolutely free!  Do check us out in Facebook, Twitter, Pinterest and Google+, do not forget to subscribe to get the latest news, tutorials and awesome design works for your inspiration!

Read more posts by

Tutorial Tuesdays – 5 Amazing Vector Portrait Tutorials!

The human face is the one of the most drawn, painted and photographed part of the human body. Most aspiring artists start with working on recreating the human face in their drawings and try to capture emotions. Vector art on the other hand has been a staple art style and has been becoming one of the favorites of artists today.
 

 
That is why today we here at You the Designer are providing you, our dear readers some of the most amazing vector portrait tutorials both old and new that we have found all over the Internet to fill your noggins of knowledge and inspiration. Let’s get crackin’ shall we?
 

1. How to Create a Self Portrait in a Geometric Style
A simple and yet fun exercise that will turn your portrait into a Picasso-inspired piece that you can do in a few hours using Adobe Illustrator.
 
 

2. Texture Effects for Vector Portraits
Instead of making a regular portrait why not turn your portrait in to a sort of map. This amazing tutorial also teaches you how to put textures in you work.
 
 

3. How to Create a Zodiac-Themed Portrait in Adobe Illustrator CS5
Big fan of Zodiac signs? Try turning yourself into one! This tutorial is great for those who have learned the tricks and quirks of the pen tool.
 
 

4. Layer up Vectors for unique Effects
If you think you are savvy enough maybe you should try and add some twist to your portrait by using a dripping effect.
 
 

5. Vector Portraits
Danielle Caballero shows us how to turn ordinary photos into amazing illustrations by using Adobe Photoshop.
 
What do you guys think? Share your thoughts below at the comments section and if you have tried using any of these awesome tutorials do share to us what you guys have done! Looking for the perfect print template? We’ve got them here and its free! Just hit the jump here. Check us out in Facebook, Twitter, Pinterest and Google+. Lastly don’t forget to subscribe to get the latest in everything design and awesome!

Read more posts by

How To Build a Fullscreen Background Video Player

After looking over countless jQuery plugins I have seen a lot of new HTML5 video techniques. The audio and video elements have created a new method of publishing digital media, streaming off a web server. But developers have been hard at work customizing these features to be used within advanced layouts.

In this tutorial I want to look at using big video backgrounds within typical website layouts. I’ve chosen the jQuery plugin BigVideo.js which includes a list of resources in the documentation. We can setup genuine HTML5 videos streaming as backgrounds behind the main page content. It is not an easy setup, but I’ll provide a clear step-by-step process to follow along.

How To Build a Fullscreen Background Video Player

Single DemoPlaylist DemoDownload Source Code

Staging the Document

I am starting off by creating the typical HTML5 doctype and header format. There are a lot of dependencies we need to include within the header for this effect to work. Most of the scripts are included within BigVideo’s download page but I’ve added a small list below:

Now this list does not include the two CSS and JS files needed for BigVideo to work. Altogether that is 6 files we need, split into 5 JS scripts and one CSS stylesheet. It is a lot, but you don’t often find high-quality background video plugins with this much flexibility. Also many of these libraries can be hosted on various CDNs. Check out my sample header code to get an idea:

<!doctype html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>BigVideo Background Demo Page</title>
  <meta name="viewport" content="width=device-width">
  <link rel="shortcut icon" href="http://vandelaydesign.com/favicon.ico">
  <link rel="icon" href="http://vandelaydesign.com/favicon.ico">
  <link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
  <link rel="stylesheet" type="text/css" media="all" href="css/bigvideo.css">
  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Nunito:400,700">
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
  <script type="text/javascript" src="js/jquery.imagesloaded.min.js"></script>
  <script type="text/javascript" src="http://vjs.zencdn.net/c/video.js"></script>
   <script type="text/javascript" src="js/bigvideo.js"></script>
</head>

The actual body text requires a type of absolute or relative positioning based on a container. This happens because our BG video will load after the DOM finishes, and so it’ll cover up all the HTML content. That is, unless it is positioned relative to the rest of the page. I’ll explain a bit of my CSS in the next section.

Content Positioning

I haven’t done much editing inside bigvideo.css since it’s not needed so much. Some of those styles you may wish to update based on differences within your own layout. But it is also possible to just rearrange elements in your current design based on new CSS properties.

#wrap {
  position: relative;
  color: #fff;
  margin: 50px 20px 420px 100px;
  padding: 25px 35px;
  width: 550px;
  background: rgba(0,0,0,0.55);
  -webkit-border-radius: 7px;
  -moz-border-radius: 7px;
  border-radius: 7px;
}

p { font-size: 1.35em; line-height: 1.25em; font-weight: normal; margin-bottom: 12px; }

a { color: #95c3d6; }

a:hover { color: #bedeec; }

h2 { font-size: 2.55em; font-weight: bold; line-height: 1.75em; color: #fff; text-shadow: 1px 1px 0px #333; font-family: 'Nunito', 'Trebuchet MS', sans-serif; }

The most important codes I’ve added pertain to the #wrap div and its position on the page. Although I have setup specific values for margins & width, you can use min-max width or different units of measurement to get the exact fit needed. I am using the position:relative property because it forces the wrapper content’s placement to appear on top of the video.

Also you’ll notice that I have included a third-party Google webfont attached into the header text. This is a nice way of sprucing up your pages so they do not look as bland. The key is picking a small font which won’t hog bandwidth and elongate download speeds.

Adding the Video JavaScript

To wrap it all together I’d like to go over some of the different settings within BigVideo’s API. Much of the video.js API can still be attached onto the video player. This means you can manually play, pause, reset volume, and various other tasks.

<script type="text/javascript">
  var BV;
  $(function() {
    // initialize BigVideo
    BV = new $.BigVideo();
    BV.init();
    BV.show('http://video-js.zencoder.com/oceans-clip.mp4',{ambient:true});
	});
</script>

You can find this block of code inside my index.html page down at the bottom closing tag. Each of these lines is required to initiate a basic video background effect without too many fancy options. Inside the show() method we are passing in 2 different parameters. The first is a self-hosted CDN mp4 file directly from the Video.js website. The second value is setting our video to “ambient” which means the sound will not play.

Based on your needs for each website this may be an important option to setup. Not everybody enjoys having sounds playing automatically – or even at all! This option is completely up to each developer and may be omitted if you’d like to use the default state. Additionally I want to share the demo codes for setting up more than one video source type, as seen below.

$(function() {
  // initialize BigVideo
  var BV = new $.BigVideo({useFlashForFirefox:false});
  BV.init();
  BV.show('media/videos/oceans-clip.mp4', {altSource:'media/videos/oceans-clip.ogv'});
});

Creating Video Playlists

The last technique I want to cover is how to build customized playlists for multiple videos. I have rarely seen websites which are currently utilizing this technique but it does offer a lot of unique substances for media fanatics. The quickest way to setup a video slideshow is to offer multiple source options for the first variable parameter.

$(function() {
  // initialize BigVideo
  BV = new $.BigVideo();
  BV.init();
  BV.show(['media/videos/bg01.mp4','media/videos/bg02.mp4','media/videos/bg03.mp4'],{ambient:true});
}

You can see how easy it is chaining settings together within the same method call. BigVideo definitely provides a stable solution for HTML streaming backgrounds. Even older browsers can support the players based on FLV/Flash fallbacks. Now one other feature of the playlist is to allow users the option of switching between videos. This requires the Modernizr JavaScript library which I have included with my demo examples.

We can duplicate this effect by setting up anchor links with href values targeting the different videos. Then apply a jQuery click event handler to update the BV.show() method. You can see my sample code below.

$('.playlist-links').on('click', function(e) {
  e.preventDefault();
  BV.show($(this).attr('href'));
});

You should be able to rename the target class into anything you’d like. Also the added videos will display a small play feature at the bottom of the screen. This isn’t added by default, but you may configure the options in the BigVideo() setup method. There is a lot of initial work required to get the scrip running, but it is worth the outcome for such an incredible effect on your latest web project.

We have covered a lot of the more common features when using BigVideo.js background videos. However you can check out more examples by visiting the Github issues area which includes frequently asked questions. As more people start using the plugin there will be more solutions for problems which pop up time-and-time again.

How To Build a Fullscreen Background Video Player

Single DemoPlaylist DemoDownload Source Code

Final Thoughts

I hope some developers may put this code to good use. Websites using big images and videos in backgrounds tend to draw in more attention from visitors. These are key selling points for branding and marketing, which is crucial for any successful business. Although this design style will not fit every website I’m sure this plugin will be fun to play around with.

Aside from the resources on the BigVideo Github page you may also download a copy of my tutorial demo source code. This zip archive includes just the basic files you’ll need to get this up and running properly. But along with new ideas we’d also like to hear any questions or suggestions from readers. And be sure to let us know if you launch any websites utilizing this video background effect!

About the Author:

Jake is a freelance writer and frontend web developer. He can be found writing in many blogs on topics such as mobile interfaces, freelancing, jQuery, and Objective-C. Check out his other articles throughout Google and follow his tweets @jakerocheleauJake’s Google+ profile.

How To Code a Vertical Accordion Nav Menu with jQuery

Website navigation is an important aspect to any functioning layout. Users will often be looking for methods to traverse over your pages, and sometimes this requires a bit of creativity. I love the idea of vertical navigations especially with sub-menu links.

In this tutorial I will demonstrate how we can build a simple vertical navigation accordion menu using CSS3 and jQuery techniques. We can build custom styles and format the links to slide down & up on each click. Using this method we can also build sub-menu links, splitting up headers by ID or class names. Follow along with the ideas below and feel free to download a copy of my source code.

How To Code a Vertical Accordion Nav Menu with jQuery

Live DemoDownload Source Code

Document Structure

As with most of my tutorials, I am starting off with the typical HTML5 doctype and other extraneous scripts. These 3rd party docs include the latest jQuery library, the html5shiv document, and a custom Google Webfont used in the page heading.

<!doctype html>
<html lang="en-US">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>Vertical jQuery Accordion Nav Menu</title>
  <meta name="author" content="Jake Rocheleau">
  <link rel="shortcut icon" href="http://vandelaydesign.com/favicon.ico">
  <link rel="icon" href="http://vandelaydesign.com/favicon.ico">
  <link rel="stylesheet" type="text/css" href="styles.css">
  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Merienda:400,700">
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <script type="text/javascript" language="javascript" charset="utf-8" src="nav.js"></script>
<!--[if lt IE 9]>
  <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

The other local files I am including are named styles.css and nav.js. All the page styles are fitted inside our stylesheet while I have separated the jQuery code into a new file as well. The actual page HTML is easy to follow since we are building a nav element using unordered list items.

<nav>
  <ul id="nav">
    <li><a href="#">Animation</a>
      <ul>
        <li><a href="http:/www.google.com/search?q=design+cartoons+animation">Cartoons</a></li>
        <li><a href="http:/www.google.com/search?q=design+comic+strips+inspiration">Comic Strips</a></li>
        <li><a href="http:/www.google.com/search?q=how+to+clip+video+footage">Video Clips</a></li>
        <li><a href="http:/www.google.com/search?q=design+create+animated+gifs">Web GIFs</a></li>
      </ul>
    </li>
    <li><a href="#">Graphic Design</a>
      <ul>
        <li><a href="http:/www.google.com/search?q=photoshop+tutorials+graphics+design">Adobe Photoshop</a></li>
        <li><a href="http:/www.google.com/search?q=digital+branding+graphics+logos">Branding & Logos</a></li>
        <li><a href="http:/www.google.com/search?q=graphics+design+marketing">Digital Marketing</a></li>
        <li><a href="http:/www.google.com/search?q=graphic+design+illustrations">Illustrations</a></li>
        <li><a href="http:/www.google.com/search?q=infographics+inspiration">Infographics</a></li>
        <li><a href="http:/www.google.com/search?q=product+design+inspiration">Product Design</a></li>
      </ul>
    </li>

The whole block is wrapped inside a <nav> element which is fitted using an unordered list. Each top-tier list item is given a link along with another internal <ul>. This secondary list is the actual list of links which will be displayed. The first set of list items are your navigation labels which behave as containers.

After clicking on each header we will show/hide the internal navigation links. This situation can get tricky when trying to implement sub-navigation and sub-sub-navigation if you want to show/hide those as well. A better solution is to nest a third <ul> element which is also displayed immediately with all the other links, but rendered using additional padding.

Styling Page Elements

The default CSS styles I follow are based on Eric Meyer’s CSS resets with some other custom properties. I always include the box-sizing property along with the vendor-specific prefixes defined using border-box. This forces all margins and padding to be limited at the maximum width and not to add any additional pixels to box containers.

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  outline: none;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
html { height: 101%; }
body { font-size: 62.5%; line-height: 1; padding-bottom: 65px; font-family: Arial, Tahoma, sans-serif; background: #c5bde5 url('images/bg.png'); }

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
ol, ul { list-style: none; }

blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
strong { font-weight: bold; } 

table { border-collapse: collapse; border-spacing: 0; }
img { border: 0; max-width: 100%; }

h1 { font-family: 'Merienda', 'Trebuchet MS', Verdana, sans-serif; font-size: 2.95em; line-height: 1.7em; margin-bottom: 20px; font-weight: bold; letter-spacing: -0.03em; color: #675d90; text-shadow: 2px 2px 0px rgba(255,255,255,0.65); text-align: center; }
Also I have setup each h1 header element to use our custom "Merienda" font family. Along with some cool text shadows, we can see a very unique effect in the page typography. I have applied similar text shadows onto the accordion text so the links are readable at a glance.

/* nav menu styles */
#nav { 
  display: block; 
  width: 280px; 
  margin: 0 auto; 
  -webkit-box-shadow: 3px 2px 3px rgba(0,0,0,0.7);
  -moz-box-shadow: 3px 2px 3px rgba(0,0,0,0.7);
  box-shadow: 3px 2px 3px rgba(0,0,0,0.7);
}

#nav > li > a { 
  display: block; 
  padding: 16px 18px;
  font-size: 1.3em;
  font-weight: bold;
  color: #d4d4d4;
  text-decoration: none;
  border-bottom: 1px solid #212121;
  background-color: #343434;
  background: -webkit-gradient(linear, left top, left bottom, from(#343434), to(#292929));
  background: -webkit-linear-gradient(top, #343434, #292929);
  background: -moz-linear-gradient(top, #343434, #292929);
  background: -ms-linear-gradient(top, #343434, #292929);
  background: -o-linear-gradient(top, #343434, #292929);
  background: linear-gradient(top, #343434, #292929);
}
#nav > li > a:hover, #nav > li > a.open { 
  color: #e9e9e9;
  border-bottom-color: #384f76;
  background-color: #6985b5;
  background: -webkit-gradient(linear, left top, left bottom, from(#6985b5), to(#456397));
  background: -webkit-linear-gradient(top, #6985b5, #456397);
  background: -moz-linear-gradient(top, #6985b5, #456397);
  background: -ms-linear-gradient(top, #6985b5, #456397);
  background: -o-linear-gradient(top, #6985b5, #456397);
  background: linear-gradient(top, #6985b5, #456397);
}

The nav container itself is given a small box shadow and fitted to a maximum width of 280px. You can obviously adjust this container to fit your layout, which defines the purpose for using the extra nav element. But since we are using CSS3 gradient backgrounds the whole nav block is very fluid.

All the anchor links are targeted using parent-child relationships. The direct parent selectors arrow syntax follows that we only want anchor links directly inside an <li> contained inside the #nav element. This is also true on hover and when the navigation menu is open (via the applied CSS class .open).

Sub-Navigation CSS

One last key point to our stylesheet deals with the internal anchor links. Since each li element contains another <ul> for the links, we need to hide these by default. Then after the user clicks on a container link we display all the internal elements.

#nav li ul { display: none; background: #4a5b78; }

#nav li ul li a { 
  display: block; 
  background: none;
  padding: 10px 0px;
  padding-left: 30px;
  font-size: 1.1em;
  text-decoration: none;
  font-weight: bold;
  color: #e3e7f1;
  text-shadow: 1px 1px 0px #000;
}
#nav li ul li a:hover {
  background: #394963;
}

This is easily accomplished using the display: none; property on any ul element inside the navigation list items. For adding another level of navigation you wouldn’t need to hide anything else, because it will show/hide at the same time as the top links. But these can be targeted as another internal ul element like this: #nav li ul li ul a.

jQuery Accordion Effects

We have the entire block element displaying properly, so now we need to create the JavaScript animations. I have created a new document nav.js and opened the typical jQuery DOM function, checking the page document has finished loading before running any codes.

$(document).ready(function(){
  $("#nav > li > a").on("click", function(e){
    if($(this).parent().has("ul")) {
      e.preventDefault();
    }

My jQuery selector is targeting only specific anchor links found directly inside the #nav container. If the anchor has a sibling <ul> element then we know it has a navigation to display, and so we don’t want to load the href value when clicked. Then we need to check if the current link is already open, and if so arrange the other elements appropriately.

    if(!$(this).hasClass("open")) {
      // hide any open menus and remove all other classes
      $("#nav li ul").slideUp(350);
      $("#nav li a").removeClass("open");

      // open our new menu and add the open class
      $(this).next("ul").slideDown(350);
      $(this).addClass("open");
    }

    else if($(this).hasClass("open")) {
      $(this).removeClass("open");
      $(this).next("ul").slideUp(350);
    }
  });
});

The first if/else logic check determines if the current anchor does not have the class .open. If so we need to hide any already open menus on the page and then open our newest one. Otherwise we check if the link already has the class and the user clicked it to close. In this scenario we run .removeClass() and .slideUp() on the targeted list element.

You can actually customize the duration values inside the sliding functions. jQuery’s documentation page explains how you can setup the current duration value in milliseconds, and also set a custom easing profile via jQuery UI. For this demo I am using the basic “linear” easing effect. But the jQuery UI library is very small and you may consider using a different easing function in future projects. You can try out examples of these effects to determine if custom easing is something you would want to include.

How To Code a Vertical Accordion Nav Menu with jQuery

Live DemoDownload Source Code

Final Thoughts

I hope this tutorial can offer a solution for web developers who need to build relatively simple accordion-style widgets. Any typical website layout is often crammed with important content and lacking in additional space. Sometimes you just cannot fit a horizontal navigation into a fitted place. However you can easily implement this code into a sidebar or floating alongside the page content.

Definitely check out my live demo above and see how this menu works in modern browsers. If you have the spare time download a copy of my source code as well. You are free to play around and customize this to your own liking, and it should work beautifully within any project. Additionally let us know your thoughts or questions on the tutorial in our comments discussion area.

About the Author:

Jake is a freelance writer and frontend web developer. He can be found writing in many blogs on topics such as mobile interfaces, freelancing, jQuery, and Objective-C. Check out his other articles throughout Google and follow his tweets @jakerocheleau. Jake’s Google+ profile.

CSS3 Image Gallery with Dynamic Caption Text

Get quality hosting for as little as $4.95 per month with Bluehost.

I have run into lots of tutorials on the web focused around creating stunning image galleries. These often include photo boxes or alternate JavaScript-enhanced functionality. Nominally in the modern era of web design there isn’t any problem with dynamic scripting.

For this tutorial I want to show how we can build a standards-compliant HTML5/CSS3 image gallery with fading captions. We will be using CSS3 transitions to create the animated effects. Also I have been working with a number of CSS3-specific properties on this tutorial alone. It leaves room for interpretation if you wanted to implement a JavaScript frontend animation using CSS3 as a fallback.

CSS3 Image Gallery with Dynamic Caption Text

Live DemoDownload Source Code

Creating the Page Document

To get us started I have created two new files inside my project directory. First is the typical index.html along with a styles.css for the CSS stylesheet. Now aside from the actual images this is all we will need to get the layout working properly.

I’ll first go over the small header portion and main document structure. I have included only one external JavaScript link to the Google html5shiv script. This will force newer HTML5 elements to render properly in older versions of Internet Explorer. Typically we would notice buggy rendering for elements such as header, footer, aside, and section.

<!doctype html>
<html lang="en-US">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>CSS3 Dynamic Image Captions Demo</title>
  <meta name="author" content="Jake Rocheleau">
  <link rel="shortcut icon" href="http://vandelaydesign.com/favicon.ico">
  <link rel="icon" href="http://vandelaydesign.com/favicon.ico">
  <link rel="stylesheet" type="text/css" href="styles.css">
<!--[if lt IE 9]>
  <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

Inside the body element I’m using some very simple HTML5 markup. I have the whole layout wrapped inside a div which is centered on the page. Then I am using figure as our HTML5 container element housing each image/caption pair.

<figure>
  <img src="images/01-sketching.png" alt="tree sketching">
  <figcaption>
    Sketching (<a href="http://dribbble.com/shots/452443-sketching" target="_blank">Source</a>)
  </figcaption>
</figure>

<figure>
  <img src="images/02-strawberry-waffles.png" alt="Fresh Strawberries and Waffles">
  <figcaption class="light">
    Strawberries and Waffles (<a href="http://dribbble.com/shots/459466-waffles-with-fresh-strawberries" target="_blank">Source</a>)
  </figcaption>
</figure>

This is the quickest and most properly-semantic way to go about coding images on the web. The whole image caption gallery could be wrapped in another container on your page, as this wouldn’t affect any of the internal content. All you need to do is make sure the whole image gallery is encased inside the .clearfix class. This will clear all our floating images and keep the document height linear.

Stylin’ with CSS

Before we jump right into the styles I want to point out a bit in my HTML code above. You will notice on the 2nd figure element I have added the class .light onto our figcaption. This is an updated style class for giving the caption a white background with dark text, as opposed to the dark background with lighter text. Test out both color schemes and see which one you like the best.

/* image figures */
figure { 
  float: left;
  position: relative;
  padding: 3px;
  margin-right: 15px;
  margin-bottom: 1.35em;
  background: #fff;
  -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
  -moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
}

figcaption {
  width: 300px;
  position: absolute; 
  background: rgba(0,0,0,0.6);
  font-size: 1.2em; 
  color: #fff; 
  padding: 10px 16px; 
  opacity: 0;
  left: 3px; 
  bottom: -10%;
  -webkit-transition: all 0.44s ease;
  -moz-transition: all 0.44s ease;
  -o-transition: all 0.44s ease;
  transition: all 0.44s ease;
}
figcaption a { color: #cce1ef; }
figcaption a:hover { color: #a9cbe1; }

figure:hover figcaption { opacity: 1; bottom: 5px; }

figcaption.light {
  background: rgba(255,255,255,0.6);
  font-size: 1.2em;
  color: #444;
  -webkit-transition: all 0.44s ease;
  -moz-transition: all 0.44s ease;
  -o-transition: all 0.44s ease;
  transition: all 0.44s ease;
}
figcaption.light a { color: #60a7d7; }
figcaption.light a:hover { color: #4d92c0; }

You will notice all of these CSS styles are put together in the same place. Each figcaption element is positioned absolutely while the figure elements have a position: relative; value. This will make it easier to place the caption box just outside the figure container and have it appear to fade in during hover.

The figcaption element has all of the transition effects added as well. The distinction is that we’re animating the figcaption element whenever a user hovers over the figure container. This works great towards building a systematic relatable user experience, since your visitors can still see the full image without pesky text getting in the way.

/* core body setup */
#topbar { position: fixed; top: 0; width: 100%; height: 45px; z-index: 999; background: #1b1b1b; border-bottom: 1px solid #575656; padding-left: 35px; }
#topbar a { line-height: 45px; font-size: 1.4em; font-weight: bold; color: #fff; }

#wrapper { width: 1000px; margin: 0 auto; padding-top: 70px; }
#gallery { padding: 0px 15px; display: block; }

This is the smaller portion of our custom CSS which is responsible for the page layout design. In the demo I have placed a static header bar which scrolls along the top of the page. Additionally the wrapper is limited to 1000px for the purposes of this demo. Although it would be completely reasonable to update this value, even into a responsive image gallery.

Resets and Clearfix

I also want to share these last snippets of CSS from my stylesheet example. You can get all of this from downloading my source code below, but it’s worth a quick explanation for other developers who are interested.

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  outline: none;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
html { height: 101%; }
body { font-size: 62.5%; line-height: 1; font-family: Arial, Tahoma, sans-serif; background: #c9d7e0 url('images/bg.png'); padding-bottom: 65px; }

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
ol, ul { list-style: none; }

blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
strong { font-weight: bold; } 

table { border-collapse: collapse; border-spacing: 0; }
img { border: 0; max-width: 100%; }

I am using a CSS reset kit based off Eric Meyer’s resets. In the big long selectors list at the top I have added box-sizing properties to keep the border-box ratio. This will force all widths to stay within the defined limit, causing padding/margins to calculate this into the final display. Plus I have some extra padding on the body to add space at the bottom of the page (otherwise captions look to be coming from nowhere).

.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
.clearfix { display: inline-block; }

html[xmlns] .clearfix { display: block; }
* html .clearfix { height: 1%; }

And finally this is the clearfix code I am using to contain the entire gallery. You won’t notice much in the demo here, but you will notice the effect if you have a sidebar or footer content displaying afterwards. The clearfix will force any floated container elements to pretend as a natural part of the DOM, even though the internal content is floated and removed from the document hierarchy.

And that should wrap it all up! What a simple effect to create one amazing outcome for your blog or personal website. Definitely check out my demo below if you haven’t already seen it, and feel free to download & manipulate my source code to your own liking.

CSS3 Image Gallery with Dynamic Caption Text

Live DemoDownload Source Code

Final Thoughts

The codebase here is very simple even to new web developers. Anybody fairly well-versed in CSS3 shouldn’t have a problem following my code. Additionally we are following typical HTML5 standards by using the figure/figcaption syntax.

I would recommend downloading a copy of my source code here and seeing how it can apply into your own layouts. Much of the code may be copied/pasted into your own documents and still work perfectly without any changes. Although feel free to make edits or updates to further blend into your layout. Additionally if you have ideas or questions on the tutorial feel free to share with us in the comments discussion area below.

About the Author:

Jake is a freelance writer and frontend web developer. He can be found writing in many blogs on topics such as mobile interfaces, freelancing, jQuery, and Objective-C. Check out his other articles throughout Google and follow his tweets @jakerocheleau. Jake’s Google+ profile.

Coding a Bare-Bones HTML/CSS E-mail Newsletter Template

There are a lot of tutorials out there explaining the major benefits of building an e-mail newsletter. It definitely draws attention to your website and helps regular readers keep up with new publications. But not everybody has the time or knowledge to build their own newsletter design.

In this tutorial I want to go over the process of building a very basic HTML newsletter. I’ll explain some key steps along the way and you can grab a copy of my source code as well. When you’re building HTML code for e-mail clients the work process is a whole lot different. But once you understand the basics you’ll have an easier time working with more complex layouts.

Coding a Bare-Bones HTML/CSS E-mail Newsletter Template

Live DemoDownload Source Code

Basic E-mail Rules

We need to build the entire HTML template with CSS styles all included inside one file. The typical HTML5 standards are mostly thrown out the window for e-mail designs.

The reasoning is that you’re not building a page to display in HTML5-capable web browsers. People will be reading your newsletters in e-mail clients such as Gmail, Hotmail, AOL Mail, Apple Mail, or possibly Microsoft Outlook. Each of these titles run a different rendering engine in some regards.

This is why you’ll always want to keep CSS styles inline with your elements. This is the best way to override any default styles when first loading the page. Additionally most of these e-mail providers will strip tags out of your documentsection, which may include CSS styles. The safest solution is to always keep CSS inline and copy them over for repeating elements.

Starting the Document

I’m beginning my code exactly as we would any typical webpage. I’m using the XHTML 1.0 Strict doctype since it provides the strictest set of rules for HTML markup. Some of the popular e-mail providers will actually strip doctype data, so this isn’t a super important element.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Newsletter Demo</title>
</head>

The content-type and charset values are definitely an important piece. Even if the tags are stripped this extra information isn’t detrimental to the layout design. I have also setup the viewport with a 1x scale for mobile screens. This will help if you’re redirecting users to open the newsletter in a browser.

Wrapping Body Content

The entire layout design should be coded using HTML tables. This feels like we’re going back into the 1990s with the early days of HTML4 specifications. But in many ways e-mail technology has not been given an improved rendering engine. So we need to build for these specs and tables are simply the quickest way to satisfy the majority of software.

To get started I’m giving the main body tag a dark-grey background color. This will match the wrapper table’s background and should fill the entire document. A width of 100% will make sure the whole page behaves as a container, while the central tables are limited at 550px.

<body bgcolor="#3f3f3f" style="width:100%;margin:0;padding:0;background:#3f3f3f;">
  <!-- main table wrapper -->
  <table border="0" cellspacing="0" cellpadding="0" width="100%" style="background:#3f3f3f" bgcolor="#3f3f3f">
    <tbody>
      <tr>
        <td>
        <!-- top head links -->
        <table align="center" border="0" cellpadding="0" cellspacing="0" width="550">

The first table is our container while the second table is used for displaying content. In this case I’m including a series of small links at the top of the e-mail so users can unsubscribe or check out the full page in their web browser.

<td align="center" valign="middle">
  <p style="font-size:11px;color:#fff;font-family:Arial,Tahoma,sans-serif;">We have you currently subscribed to receive our weekly site newsletter.
  <br />
  Is this message too small? <a href="#" style="text-decoration:none;" target="_blank"><span style="color:#728fd9;">Open a copy in your web browser.</span></a>
  <br />
  Sick of getting these updates? <a href="#" style="text-decoration:none;" target="_blank"><span style="color:#728fd9;">Unsubscribe now.</span></a></p>
</td>

This is the inner table data element containing a brief paragraph of text. I’m using line breaks so we don’t have awkward margins with multiple paragraphs. But also notice how I have included the specific anchor link styles inline on each element in the text. This is verbose when initially coding a template, but it also provides the greatest support.

Core Newsletter Content

As you can guess by now the entire document is comprised of just a few tables. We have the very top for our header links, then underneath that another table holding the logo and some descriptive text. The 3rd table includes the entirety of our body content while the 4th behaves as a small footer with credits and further links.

<!-- newsletter content area -->
<table align="center" border="0" cellpadding="0" cellspacing="0" width="550" bgcolor="#f5f8f6" style="background:#f5f8f6;">
  <tbody>
    <tr>
      <td style="text-align:center;">
      <h2 style="font-size:22px;font-style:italic;font-weight:normal;font-family:Georgia,Times,serif;color:#636363;margin-bottom:2px;">September 2012 Publication</h2>
      <p style="font-size:12px;line-height:17px;color:#343434;font-family:Georgia,Times,serif;padding:2px 10px;">For our current newsletter we have included a series of galleries, showcases, design articles, tutorials, and even a unique WordPress theme. All of these articles can be found archived in the blog. You can visit the <a href="http://vandelaydesign.com/blog/" style="color:#5977c3;" target="_blank">website homepage</a> to find more recent articles.</p>
      </td>
    </tr>
    <tr>
      <td>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody>
            <tr>
              <td width="280" height="125" style="padding-left:6px;padding-top:4px;">
                <a href="http://vandelaydesign.com/blog/galleries/photography-logos/" target="_blank"><img src="http://byjakewithlove.com/code/vandelay/newsletter/images/photography-logos-showcase.png" alt="Showcase of Photography Logos" width="280" height="120" /></a>
              </td>
              <td width="240" height="125" style="text-align:center;padding-right:8px;">
                <h3 style="font-size:15px;color:#64686e;font-family:'Lucida Grande',sans-serif;font-weight:bold;">Showcase of Photography Logos</h3>
                <p style="font-size:11px;color:#666;font-family:Arial,Tahoma,sans-serif;padding:0 12px;margin-bottom:0;">In this post we'll showcase more than 25 logos for photographers, created by a variety of different logo designers.</p>
                <p style="margin:0;text-align:right;font-family:Arial,Tahoma,sans-serif;"><span style="font-size:11px;font-weight:bold;"><a href="http://vandelaydesign.com/blog/galleries/photography-logos/" style="color:#5977c3;" target="_blank">Read Online →</a></span></p>
              </td>
            </tr>

Inside the main content table we can generate data inside table rows. So for each new row we can split content into two columns, or keep everything at 100% width. All of the article links are split into two columns displaying the post title along with a thumbnail image.

For each alternating table row I’ve setup a different background color. This alt design style will help readers as they’re scrolling through your newsletter. Distinguishing content apart from the rest of the background will make the articles listing stand out more.

<tr style="background:#e5e9ee;">
  <td width="280" height="125" style="padding-left:6px;padding-top:4px;">
    <a href="http://vandelaydesign.com/blog/galleries/blurred-backgrounds/" target="_blank"><img src="http://byjakewithlove.com/code/vandelay/newsletter/images/blurred-website-backgrounds.png" alt="Blurred Backgrounds in Web Design" width="280" height="120" /></a>
  </td>
  <td width="240" height="125" style="text-align:center;padding-right:8px;">
    <h3 style="font-size:15px;color:#64686e;font-family:'Lucida Grande',sans-serif;font-weight:bold;">Blurred Backgrounds in Web Design</h3>
    <p style="font-size:11px;color:#666;font-family:Arial,Tahoma,sans-serif;padding:0 12px;margin-bottom:0;">In this post we値l showcase 16 examples of this blurry-background trend for your own design inspiration.</p>
    <p style="margin:0;text-align:right;font-family:Arial,Tahoma,sans-serif;"><span style="font-size:11px;font-weight:bold;"><a href="http://vandelaydesign.com/blog/galleries/blurred-backgrounds/" style="color:#5977c3;" target="_blank">Read Online →</a></span></p>
  </td>
</tr>

One more important tidbit worth sharing involves images within your newsletter. It’s always a good idea to keep images hosted somewhere on your own website, away from the other image files. Ideally you should keep these online indefinitely so that your newsletters will always be compatible even years later. But there is no other simple method to include images within your HTML document. So the best solution is self-hosting while keeping all your design assets organized.

Testing & Publishing

Once we have a completed HTML newsletter how do we test the layout within different e-mail software? The best way is to create a series of different accounts which you can use for modeling your designs. This would include a few staples which I’ve listed below:

  • Google Mail
  • Hotmail
  • Yahoo! Mail
  • Microsoft Outlook 2003/2007
  • Apple Mail

If you don’t have software like MS Outlook or Apple Mail there’s really no way to do testing for that. But it shouldn’t be difficult signing up with any of the free e-mail providers online. Keep a small text document with e-mail/password combinations just incase you forget. There is also an excellent blog post by Campaign Monitor which outlines their typical testing procedure.

As for online tools my favorite has to be Puts Mail. You don’t need to signup or create any new account. Just copy/paste your HTML code and then add up to 10 distinct e-mail addresses.

Their service will fire out all the emails at once so you can check for issues in your layout design. This is the simplest method for pinpointing bugs and rendering issues within the e-mail clients you’re testing. And the service is completely free, which is great news for web developers on a budget.

Coding a Bare-Bones HTML/CSS E-mail Newsletter Template

Live DemoDownload Source Code

Final Thoughts

I know this tutorial will help some web developers who are familiar with modern design trends but haven’t ventured into the field of e-mail designs. It will most likely require a few hours of practice before you can nail down a solid coding technique. But in many ways building a newsletter can be easier than building an entire HTML5 webpage.

Feel free to grab a copy of my source code and test it out for yourself. I’ve shared a couple resources for HTML e-mail testing which you can send out to various inboxes. Hopefully this very basic template can be used for building out your own designs for working on future projects. If you have any questions or comments on the article feel free to share with us in the post discussion area below.

About the Author:

Jake is a freelance writer and frontend web developer. He can be found writing in many blogs on topics such as mobile interfaces, freelancing, jQuery, and Objective-C. Check out his other articles throughout Google and follow his tweets @jakerocheleau. Jake’s Google+ profile.