- Jun
- 15
In a recent project on which I got the opportunity to work, I got to do some cool stuff to conquer some fun challenges. The site hasn't launched yet, so no linky for you. (Update: The Site is MIOX.com. Update again: Apparently they redesigned. Boo.)
One fun challenge was in styling dates. On the front page of the site, we feature one entry from the news section and another from the company blog. The dates were styled in a fun way, so I thought I'd share how I did it in case anybody wanted to do the same.
The code for the date uses a definition list:
<dl class="post-date">
<dt>May</dt>
<dd>06</dd>
</dl>
So, first thing I did was use a background image for list. As well as width and height attributes.
.post-date {
background: url(/graphics/date_blue.png) 0 0 no-repeat;
width:47px;
height:48px;
}
Awesome, that was easy. Let's add some font styling.
.post-date {
background: url(/graphics/date_blue.png) 0 0 no-repeat;
width:47px;
height:48px;
font-weight:bold;
color:#fff;
text-align:center
}
Next we need to specify the font sizes of the month name and day.
.post-date dt {
font-size:13px;
}
.post-date dd {
font-size:18px;
}
Lets add some margins in to move stuff around.
.post-date dt {
font-size:13px;
margin: 7px 0 0 0;
}
.post-date dd {
font-size:18px;
margin: -4px 0 0 0;
}
We used a -4px top margin in the day to tuck it in under the month just a little bit. Having them nice and close helps make it feel more like a calendar. You could also adjust the line-height to get it up in there.
Lastly, if you add a text-shadow to the list, you will get a classy looking little drop shadow behind the text. If used judiciously, the drop shadow can look really nice. The only problem is, very few web browsers currently apply the shadow. Not even Firefox does it. Safari, and other Webkit-based browsers, does render the shadow. It's just a nice little touch that really caters to the designer in me.
.post-date {
background: url(/graphics/date_blue.png) 0 0 no-repeat;
width:47px;
height:48px;
font-weight:bold;
color:#fff;
text-align:center;
text-shadow: #13708c 0 0 2px
}
That's all there is to making really classy dates. Much easier than the alternative, which would be to create 12 different month images, and 31 different day images. Then write a script to output each image, spliced together, based on the date of the post. Yuck. This method is really much less yucky and really helps unleash the designer in you.
So THAT’S how you did it!
Great tutorial Brian. Can’t wait to see the rest of the site!
§ By Mark at 6:02am on June 16 2006
Maybe it is just my eyes, but I can’t see the text-shadow differenced, just the font differences. Perhaps for my feeble eyes, adding a safari-without shadow would help. If nothing else, I could stick them in photoshop and subtract the images from each other to make it really obvious.
Nice tutorial, Brian.
§ By JohnH at 6:02am on June 16 2006
John,
Thanks! I added the screenshot of safari without the text-shadow. Hopefully that helps you see the differences.
§ By brian Warren at 6:02am on June 16 2006
That’s a nifty trick. I really have to ask though, and I’m sorry for derailing…
How did you get the thin font in the post heading? It’s actually text! I was unaware that such a thing was possible, and I’ve been killing myself for the last hour or so trying to figure out how you did that, but you seem to have hidden the post-title class away. Trade secret?
The entire site design is lovely, by the way. Probably the best blog design I’ve yet seen.
§ By Adam Bard at 6:02am on June 16 2006
Adam,
I’m using a technique called sifr, it uses javascript to replace, dynamically, the text with flash text. You can find out some juicy info about it here – sIFR
Thanks for the compliments on the site, I really appreciate it.
§ By brian Warren at 6:02am on June 16 2006
You made it sound so easy. Definition lists are so under used these days. Great tutorial. This is something I’ll need to try some time on a personal project.
§ By Derek Punsalan at 6:02am on June 16 2006