Archive for January, 2008
Replace valign with CSS
Saturday, January 26th, 2008For those trying to break away from using tables for layout and do things in CSS, the loss of the valign attribute is a problem. For some reason, the CSS people never imagined that we’d want to center anything vertically.
You might have tried to use the CSS vertical-align property in your div and discovered it had no effect. The reason for this is that div is a block element and vertical-align only applies to inline elements. So we need to use an inline element like span. But wait, you say, inline elements can’t have a height specified! Quite so. But we can emulate height with the line-height property. So we just wrap the content to be centered in an inline element with a line-height that’s the same as the parent block’s height and presto!
For example:
<span style="line-height: 50px; vertical-align: middle;">
Vertically centered!
</span>
</div>
It’s a bit of a hack, but what about web design isn’t?
Finding Emo
Saturday, January 26th, 2008The Horror of Blimps
Tuesday, January 22nd, 2008I literally laughed until I cried when I read this one.
Cross-browser dynamic JavaScript events with DOM
Thursday, January 17th, 2008I have wrestled at length with a good DOM-based way to dynamically add JavaScript events to a page. After much Googling, I pieced the following together from a number of different suggestions (credit to whoever you are). I eventually gave up on DOM because IE’s implementation is so broken, but this part works well.
It uses eval() to execute the action, so it’s not the most elegant thing, but it’s functional.
Example and source:

