I was looking into more layout-related code, and couldn't remember why .inline-block forces a vertical-align: middle.
Which got me into looking at inline blocks again... Been a very long time, really.
One of the things I never liked in my code, is that inline blocks are never properly aligned with any text content beside them.
It particularly shows in cat/title blocks, where I have to assign some kind of vertical-align hardcoded pixel value to align the icon next to the title, only the number differs on every browser... Originally I did all of my calculations on Opera, but now that I'm using Chrome on a daily basis, I keep seeing icons that are off by a pixel or two. Most people won't mind, but I do.
The thing with inline blocks, is that their height is the same as the text next to them. By default. So, I did a few tests and... It's really easy to align icons. Just remove any vertical-align crap, any hardcoded height, and then include the icon with background: url(...) no-repeat center. The 'center' is really what does it.
While there's a definite advantage to simplifying our icon code (and believe me, it will), there are also three drawbacks to this method, and this is why I'm not going to implement it without feedback.
1/ There are tons of icons, and it requires changing their HTML one by one, manually. It's okay... I can handle it. But it's not pretty.
2/ Sprited images.
- Obviously, can't set a 'center' on them, because they'll show something else on the side. So... Do we get rid of sprites for any icons that inherits .inline-block?
- Pete likes them (true enough, the sort.gif image is 90 bytes, as opposed to 146 bytes for sort_down+sort_up). However, the magic of gzip ensures that small images may sometimes compress very well through Wess. In this case, I tried doing the same code with the two separate images, and went from 29085 bytes to 29096... That's an extra 11 bytes. With a bit of CSS simplification, I went down to 29090. Only 5 more bytes... The 143 bytes in sort_down+sort_up are compressed to exactly 84 bytes, while the 90 bytes in sort.gif are compressed to 79. (And they said base64+gzip wasn't helpful to compress images... :P Well, that's probably due to the fact that there are other GIF files in our CSS, and they share similar, if not identical, headers and palettes.)
3/ If the icon is taller than the current text, it won't resize to fit. So, the icon will be partially hidden. I can't think of many situations where this is desirable.
So... What do you think..?
Which got me into looking at inline blocks again... Been a very long time, really.
One of the things I never liked in my code, is that inline blocks are never properly aligned with any text content beside them.
It particularly shows in cat/title blocks, where I have to assign some kind of vertical-align hardcoded pixel value to align the icon next to the title, only the number differs on every browser... Originally I did all of my calculations on Opera, but now that I'm using Chrome on a daily basis, I keep seeing icons that are off by a pixel or two. Most people won't mind, but I do.
The thing with inline blocks, is that their height is the same as the text next to them. By default. So, I did a few tests and... It's really easy to align icons. Just remove any vertical-align crap, any hardcoded height, and then include the icon with background: url(...) no-repeat center. The 'center' is really what does it.
While there's a definite advantage to simplifying our icon code (and believe me, it will), there are also three drawbacks to this method, and this is why I'm not going to implement it without feedback.
1/ There are tons of icons, and it requires changing their HTML one by one, manually. It's okay... I can handle it. But it's not pretty.
2/ Sprited images.
- Obviously, can't set a 'center' on them, because they'll show something else on the side. So... Do we get rid of sprites for any icons that inherits .inline-block?
- Pete likes them (true enough, the sort.gif image is 90 bytes, as opposed to 146 bytes for sort_down+sort_up). However, the magic of gzip ensures that small images may sometimes compress very well through Wess. In this case, I tried doing the same code with the two separate images, and went from 29085 bytes to 29096... That's an extra 11 bytes. With a bit of CSS simplification, I went down to 29090. Only 5 more bytes... The 143 bytes in sort_down+sort_up are compressed to exactly 84 bytes, while the 90 bytes in sort.gif are compressed to 79. (And they said base64+gzip wasn't helpful to compress images... :P Well, that's probably due to the fact that there are other GIF files in our CSS, and they share similar, if not identical, headers and palettes.)
3/ If the icon is taller than the current text, it won't resize to fit. So, the icon will be partially hidden. I can't think of many situations where this is desirable.
So... What do you think..?