I am trying to align thumbnail images in fixed square containers, both horizontally and vertically centered. While using CSS properties like height
, line-height
, and vertical-align
, I almost have it working but there is a small top offset of 2px that I can't seem to eliminate. I'm curious about the reason behind this offset.
To address this issue, I could apply a negative top margin to the image, although I prefer to find a solution that doesn't rely on this workaround (as it may cause compatibility problems across different browsers). It's surprising that I need a -4px top margin to counteract the initial 2px offset.
Can anyone provide some insights or suggestions?
You can view the code example here: http://jsfiddle.net/GlauberRocha/N6Rme/