3 ms·
I agree I should have left a demo up- I had decided I should just start over so I took some screenshots for reference then scraped it. Later as an after-thought
by tborthwick 15y ago
I agree I should have left a demo up- I had decided I should just start over so I took some screenshots for reference then scraped it. Later as an after-thought, I decided to write it up. I didn't really expect this much interest- I'll try to get it back up tonight.
The exercise was a little more than straight-up horizontal centering. It was to take two numbers randomly generated with possibly different number of digits, center them together along with an operator as a block, but right-align the text within. Also a text input field was put below. The line above the input field is just a simple border.
For reference, the CSS tutorial I looked at was http://www.noobcube.com/tutorials/html-css/horizontal-and-vertical-centering-using-css-a-beginners-guide-/ http://www.noobcube.com/tutorials/html-css/horizontal-and-ve..., but I didn't add the IE elements because I thought it was only necessary for IE 6 and 7, not 9.
So the horizonal alignment problem in IE is probably because I used display:block. But why don't the numbers line up the same in chrome and firefox? What's up with the field border being all over the place? My point is not that I know html and css well, which I clearly don't, or that this stuff is impossible. It's that even with the latest browsers and techniques, it's still easy to get very different displays. I just didn't expect that, given the huge hype surrounding html5 and css3.
- bgarbiak 15y agoThe tutorial you've mentioned overcomplicate things a bit and uses tables for layout, which is a total no-go. However, even as a regular HTML5 defender I have to admit centering stuff in HTML/CSS in not exactly a trivial task. It's not very tough either, just not something that most of the 'newcomers' could solve in a minute. You can look up my solution here: http://garbiak.com/demos/hn/ http://garbiak.com/demos/hn/ Without seeing your code it's hard to tell what exactly gone wrong, however such huge level of browser inconsistency is indeed worrisome. Never believed HTML5 would solve these kind of issues completely but the differences shouldn't be that huge.