Hey, I need to align my text labels vertically within a DIV. I set my DIV to have height X, and a DIV within it, that holds my text to height 1.3em, with the text at height 1.e em also.
Now the problem… On Linux the text fits within the box, and its top is aligned with the top of its containing DIV. On Windows though… its aligned with the bottom. This means that when I try and align the text vertically, its correct in one OS, and wrong in the other.
Is there a CSS value I can set, that defines the texts standard alignment within its DIV. If I can make it consistent from browser to browser + OS, then that would of course be ideal.
I’m afraid not, the problem persists. If you use the technique on that site, it DOES actually vertically align the text. But on Windows and Linux the result is slightly out compared to each other because of the vertical alignment of the text within its own DIV, its a real PITA.
To be clear, on I have the fonts line-height set to 1.3 em, which I understand is needed to show the text + decening text elements (g etc). On Linux this box is rendered with the top of Caps letters aligned hard with the top of the DIV. On Windows however, there is a 2 or 3 px gap, with the text aligned more centrally within the DIV. This 2 or 3px difference is scuppering my attempts to vertical align accurately in small DIVs.
If I could get either behaviour to be consistent, across all platforms, I could account for either, but as it is, I have per Os differences. I really want to avoid conditional CSS for this if at all possible.
Fonts will vary cross browser as they are made differently and will have different heights for ascenders and descenders and indeed may have space at the top and bottom as part of the font so you will never get pixel perfection.
You should be able to align the text within reasonable limits but remember that ems are also rounded up and down and may differ cross platform by 1px.
If you posts a small demo exhibiting the problem you are stuck with then we will see if we can improve it for you or say whether it’s something that you are stuck with.