On to the screen.css
First thing I do in my screen.css is use a reset. The one I use targets just the elements I’m most likely to use and only does margin:0; padding:0; on them, and pulls the border off IMG and FIELDSET. There are larger resets, but those usually waste time setting things I don’t even use or wouldn’t use those values for anyways – and there are smaller resets that wreak havoc in forms. Much like Goldilocks, I find this one to be ‘just right’.
body – I pad body so we get that nice all-around border instead of having to put it into the image. The text-align’s comment says it all - IE 5.x doesn’t obey margin:auto; for centering elements, but incorrectly obeys text-align, so that’s an easy fix that I basically add out of habit at this point.
The font size declaration is in % since that’s what the text-content/page copy should always be in (see the WCAG). We will use PX in a couple places, but when we do it will be on fonts so huge NOBODY is going to complain about them not resizing in IE or adjusting to the system metric.
#outerWrapper – The position:relative makes certain all browsers (mostly opera and IE) will redraw the window properly when resized due to our min-width and max-width values. I set it up as semi-fluid since 100% fluid could be problematic for users to read really long lines of text. I wasn’t sure if you were going for fixed or fluid, so I went semi-fluid. You want fixed, just set a width here and yank the min/max code. The margin:0 auto; is for centering in standards compliant browsers, and of course a little FAC never hurt anyone.
The two values – 720px and 1200px are based off 800 and 1280 friendly. We’ve got 48px padding on body, and need another 32px on average to compensate for the scrollbar (if any) - that’s 80 px total, so 800-80==720, 1280-80==1200.
* html #outerWrapper – IE6/earlier doesn’t know what min-width and max-width are, but we can fake it using the IE specific ‘expression’ property. This lets you use javascript to set a value (I WISH that was adopted into CSS3). Before I run that script I set the 800px wide friendly width of 720px so if javascript is disabled, they get the ‘safest’ width.
#outerWrapper a - and it’s psuedostates – Just set up some pretty appearance on the anchors to work with our background color and images. You’ll notice I don’t just trap :hover - the other two are to make sure keyboard navigation across all browsers trips the hover states.
.borderTop,
.borderBottom - these share so much in common we declare their values together. I set overflow:hidden just in case to wrap the floats, set the height for the same reason. The 1px font-size is to fix a bug where IE won’t allow any element to be shorter than the current font-size; at 24px height this shouldn’t be an issue, but I set the value anyways JUST IN CASE. Finally, we load the background image. If you look at the image:
You can see that our 0 0 position (aka top left) will show the top left of our rounded part. The left 2048px is our rounded corners, I’ve got 1px of separation between the two sides to compensate for FF being a retard when resizing content, so the right 2047px is the other side - this means the maximum dynamic width we’re allowed to let these borders go is 2047px - given I put a max-width on it, I don’t forsee any issues.
… and even for their ridiculous dimensions (2048x48), the filesize is quite modest (2k) and by only using one image for each border set, we reduce the number of handshakes to the server greatly speeding up the page load. More separate files == BAD. (I generally try to bring a contentless template in under 16 separate files)
.borderBottom – this gets one value change, background-position. Sliding it up 24px reveals the bottom half of the image instead of the top half.
.borderTop div,
.borderBottom div – Again, so much in common we declare them together. Floating them right and making them 24x24 will let us draw the other corner over the parent div’s background. We just slide it over 2024px to reveal the right hand corner. Bam, we’ve got sliding doors.
.borderFirstSide – First is a height:1%; – this is there JUST to trip haslayout making IE7/earlier behave. If you don’t know what haslayout is, Google it, it’s a subject that’s been beat to death. The left padding pushes our next element off so only the left side is shown on our sliding doors.
.borderSecondSide – and this is why the tiled sliding doors HAS to be on the right side of our image. The image has to be aligned top-right since we can’t fix the height of this to say a numeric value for it’s position. The padding is just there to equalize pushing the content in away from the border equally.
That’s most of our border code covered!
#mainMenu,
#footer ul – I styled these the same way jsut because it looked nice and consistent. We’ve got centering already set from our body so we don’t need to play with that, so we just strip bullets and pad the bottom a bit to make it pretty.
#mainMenu li,
#footer li – Set them inline, so we can pretend they don’t exist.
#innerWrapper – Oooh, colors. The white background will be overwritten by our border images, and is provided just for people browsing with images disabled. (like many handheld users do).
#innerWrapper a - and it’s psuedostates – since our background changed, we need to adjust the colors and appearance. Thankfully a child ID trumps the parent when it comes to specificity.
#innerWrapper .borderTop,
#innerWrapper .borderBottom,
#innerWrapper .borderTop div,
#innerWrapper .borderBottom div,
#innerWrapper .borderFirstSide,
#innerWrapper .borderSecondSide – The only thing we need to change on these is what image is used since all the dimensions are the same.
#innerWrapper p – I prefer to use padding on these instead of margin, just because margin collapse around floats (like our borderTop and borderBottom) can drive you nutters cross-browser. 0.5 top/bottom puts 1EM between them, without making the edge facing the bottomBorder div end up too big.
h1 – ok, this gets a little tricky. The h1 is set to position:relative and the full width so that we can use text-align:center to center the span inside it. This is entirely to smack IE5 in line. The 100% width also trips haslayout fixing any absolute positioning bugs we might encounter with the absolute positioned bold tag. The fixed height and overflow:hidden is there to chop off the images-off text should someone still be using a outdated text resizing method like the one FF 2.x uses and 3.x lets you manually select – basically making it behave like the sweetly retarded cousin of Nyetscape 4 that it really is.
h1 span – display:block lets us set a width, the overflow is to chop off the width the same way the h1 does it for height - we have to do these separate if we care about IE6/earlier. The top padding and text-indent are just to make it a bit prettier, and of course our orange color.
h1 span span – the blue text is of course larger, centered, and we have to unset the text-indent to make sure it centers. The negative top margin is there just to slide it up a bit to make it pretty. We could use a shorter line-height, but FF will start chopping off text at that point.
h1 b – finally our image. We absolute position the whole bold tag over our spans, set it to full width and let the background-image centering handle the rest. Now images on you get the image logo, images off you get styled text, CSS off you get a text header. Graceful degradation is the name of the game.
#footer - everything else inside this is already set, so I just add a bit of top padding to pretty it up a little making it space the same as #mainMenu does.
… and that’s it for the CSS.
Hope this helps, and any questions feel free to fire away.