Create Date Badge with Wordpress and CSS

This tutorial will walk you through creating date badges with Wordpress and CSS.

Date Badge Sample

Let's start of by adding the necessary markup to render the appropriate date format. Create a DIV element with a class of "entryDate" and three children SPANs with respective classes "postMoth", "postDay", and "postYear".
Add the PHP code to get the post date from the database as shown bellow. For more PHP date format go to http://us.php.net/date

Markup

<div class="entryDate"> <span class="postMonth"><?php the_time('M') ?></span> <span class="postDay"><?php the_time('d') ?></span> <span class="postYear"><?php the_time('Y') ?></span> </div>

Now let's add styles to make it look pretty.

First of all, set the body font-size to 10px or 62.5%. Then go ahead and set the DIV that wraps the post entry to position: relative so the date badge can be positioned relatively to it. Set margin-left to the width of the date badge plus the gap between the post entry. In this sample the margin-left is set to 4.8em.

Absolute position the entryDate and set the left to the same size as the its parent margin-left. After that, set the width to 3.5em. Next, set all the SPANs inside entryDate as block element (The reason why SPANs are being used instead of DIVs is because if the stylesheet is disabled, the date renders nicely in one line). Don't forget to centered align the text.

Change the appearance as needed, I have changed the size of the text to look more like a calendar and I've set its color to blue and white.

CSS

body { font-size: 62.5%; } .post { position: relative; margin-left: 4.8em; } .entryDate { border: 1px solid #999; font-family: Georgia,"Times New Roman", serif; left: -4.8em; line-height: 1; position: absolute; top: 0; width: 3.5em; } .entryDate span { display: block; text-align: center; } .postMonth { text-transform: uppercase; font-size: 1.2em; padding-top: 0.3em; } .postDay { font-size: 2em; } .postYear { background-color: #2358B8; color: #FFF; font-size: 1.2em; padding: 0.3em 0; margin-top: 0.3em; }

Don't forget to checkout the live demo

Demo

Browser Support

  • Firefox
  • Safari
  • Chrome
  • Opera
  • Internet Explore 7 & 8
  • Internet Explore 6

top ↑

Link Roundup: Week 12/29 – 01/04

Last week's websites that I stumble upon. Some design related, development and completely off beat topic. If you have a link that you'd like me to share with others feel free to send it me.

Web Design & Web Development

Pxtoemcom px to em Conversion Made Simple PX to EM conversion made simple. Very handy website.

Uncoverr Books Web Design & Development books reviews and interviews.


iPhone & iPod Touch Wallpapers

Type Nuts Lots of typography wallpapers for both iPhone and desktop.

top ↑

Link Roundup: Week 12/22 – 12/28

Last week's websites that I stumble upon. Some design related, development and completely off beat topic. If you have a link that you'd like me to share with others feel free to send it me.

Inspiration

Illustration Stock Huge stock illustration site

Jessica Hische Illustration Portfolio of Jessica Hische a fantastic illustrator and designer, don't forget to visit her blog.

Stephen Kelleher Portfolio of Stephen Kelleher check out his illustration.

Read the rest of this entry »

top ↑

Make A Steampunk Gear

Very cool tutorial by Buz. Make A Steampunk Gear Using Photoshop Patterns and Effects.

Steampunk Gear Tutorial

top ↑

Illustrator Tip: Select by Fill Color

A lot of times I end up with a bunch of objects all over in the same layer and it becomes very difficult to select them. That's when “Select by Fill Color” comes in handy.

Choose Unused Color

Choose an unused color and draw your objects. Choose Unused Color

Read the rest of this entry »

top ↑

Page 1 of 41234»