HTC Desire in CSS3 – Part 3
February 11, 2011
The Small Details
..~%~..~%~.. Intermission ..~%~..~%~..
..~%~..~%~..~%~..~%~..~%~..
Step 13
Back on track. Details at the top: the earpiece has two holes (4mm x 1mm, 0.5m radius, 4mm from top of phone, 1mm between).
Sometimes I guess there just isn't room for a border radius. You can hover over the phone to make it bigger.
Step 14
The htc logo is 7mm x 3mm, and 2mm from top of the surround. Really getting small here; font rendering is a bit peculiar at these scales. Let's try it with normal CSS text styles and see what happens.
Step 15
Buttons! I'll spare you all the individual measurements. Sizing, spacing and positioning - all pretty run-of-the-mill.
A little tip: display: inline-block is great for letting sized elements (like our buttons) flow horizontally, but there's a gotcha - white space between the elements will result in a stubborn gap. Hence the horrible one-liner above.
Step 16
Beautifying.
Step 17
A little highlight over the trackball.
Step 18
Button pictures - a severe case of div-itis. This is certainly taking things too far, but then it's also way too late for that particular objection.
Scaling up to work on this section alone...
Step 19
The Home button. We can make this out of 3 boxes, careful use of borders and some rotation...
I know it's daft. Shush :)
Step 20
The Menu button. Just tweak the text display settings.
It looks a little too far to the left, but we'll leave it like this - it'll be better with a drop shadow later.
In Opera, the text may be too large. That's simply because its minimum font size (a preference setting) is 9px by default.
Step 21
The Back arrow. We'll do this with some more borders on a couple of boxes.
Step 22
The Search magnifying glass. Guess what...
In Opera, this is very peculiar - still some bugs with border-radius defined in percentages. A nice table showing border-radius compliance.
In Safari/Win and Android, the border-radius isn't applied at all.
Step 23
Finally some highlights...
Step 24
Putting it all together again...
Summary
The final phone on a separate page.
And another comparison:
- Firefox 4 betaLooks best - I used it while developing.
- Firefox 3.6.13 Border smoothing is missing.
- Opera 11Gradients missing. Minimum font-size override. Small border-radius by percentage buggy.
- Safari 5.0.3 (Win)Border smoothing and percentages in border-radius are missing. Tiny border radius (earpiece) ignored.
- AndroidBorder smoothing, box shadows with zero blur, and percentages in border-radius are missing. Tiny border radius (earpiece) ignored
- Chrome Dev (10.0.648.11)Border smoothing is missing. Tiny border radius (earpiece) ignored.
- Chrome Stable (8.0.552.237)Border smoothing and inset box shadows are missing/broken. Tiny border radius (earpiece) ignored.
- IE9Gradients, transforms & transitions, and text-shadow missing.
- IE8It's kind of cute :)
Ok, that's enough now :)
Let's briefly play with another new bit of CSS and also see the advantages of getting the browser to do the graphics for us.
Hover over the phone - if you're using Webkit (Chrome, Safari), Firefox 4 beta, or Opera (creaky but just works).
This uses CSS to scale up our phone div (and move and rotate it, just for fun). Of course this happens to any kind of content inside the div being transformed - images, tables, whatever - but here, notice particularly how our curved borders, box shadows and gradients all get nicely scaled up by your browser (you may be able to see it re-rendering).
Fun, although implementations are a little buggy right now. For more: CSS3 Transitions at A List Apart, and CSS3 Transforms at 24 Ways.