I switched the nav from floar: right to left just to get away from using a negative em on positioning, not sure what the standard rule is when choosing to float left or right?
It’s not any rule, really, it’s more “what’s the least amount of work you can get away with”. If I were given a picture of this website and told to code it, I probably would have had the tagline inside the header, for example: then if it were the only text in the header I could maybe either float it, or set text-align: right on the header or the p inside the header holding the text.
Having it first before the header and then pushing it down with a margin would look mostly the same, but it’s more “positioning” to me I guess. It means we have to take the header and the background image it’s holding and figure out how to let it “slide up underneath” the tagline (and pushing it down “over” the header is then the same thing).
So, usually if I have a container and I want the stuff inside to sit to the right, if that stuff is a box then I’ll probably float it right. If it’s a series of boxes to sit next to each other then I’ll propably float them left and let them stack up against each other… and then if they need to all be sitting to the right I’d either pad the left inside of their container, or give them a wrapper and float that whole wrapper to the right.
I guess it’s more to do with how you start seeing the DOM after staring at it for several years. There are probably developers out there who prefer large margins and positioning than floats or text-align. Depends on the design, depends on what the design is supposed to do at different screen sizes, depends on how fixed the layout is.
I still can’t get those buttons to position identically in Firefox and Safari. It looks proper in Safari and in Firefox it’s still down just the slightest bit. I can live with that.
Not sure but possibly a text-size or font-size difference between those browsers… since I believe in those modern browsers the floated nav is bumped down by the floated tagline.
The last IE issue I am having is it placing the buttons much higher than other browsers. Adding a width to the nav got them in-line again but now their placement is just much too high.
They don’t seem to be “seeing” the tagline above them.
Also I notice the #header, even tho it’s set to block, isn’t expanding completely to 100% width.
I think this is because of how IE incorrectly deals with margins, margin-collapse, and floats.
The tagline is floated right and then pushed down over the header… and so any floats inside the header need to be aware of that tagline and stay under it. IE allows margins to collapse on floats (when it shouldn’t) and also has a nasty bug where floats in the same direction don’t clear each other.
So setting the header (who is not floated) to clear could fix that in IE, but then the clearing would also force the header under the tagline.
Im also confused about why those two buttons in IE are creating a opaque white box over the part of the header they are on top of? Clues?
In IE7 it looks to me more that the header actually is stopping (rather than getting covered by white). IE6 is doubling margins on that #nav box (adding display: inline right after the “float: left” line magically fixes this bug in IE6, even though it should be ignored by all browsers).
The more I look at this design, the more I worry that it’s too image-based to deal well with em’s for box sizing.
Your positions depend heavily on those background images, and images are set in px-based dimensions. So while the text itself should remain flexible (even though this means users who need larger font sizes will have a broken page…), the boxes are always going to be a little off if sized in em’s between browsers and OSes because the box size is based on the font size, which differs even between browsers (rounding errors) and OSes (available fonts).
You have a smaller font (arial) in the same font stack as a larger font (verdana). In the (unlikely) event that someone has Verdana on their computer but not Arial or Lucida, your em-based setup will get too big when Verdana is the main font.
Here’s an idea of one way to do your header. It sticks mostly to em’s except in a few places because of your header background image:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Fenton Medical Center</title>
<meta name="description" content="Fenton Medical Center" />
<meta name="keywords" content="Fenton Medical Center" />
<link rel="shortcut icon" href="favicon.ico">
<style type="text/css">
* {
margin: 0;
}
body {
padding: 5em 0;
color: #fff;
font: 100% arial, lucida, verdana, sans-serif; /*percentage font size stops an IE bug*/
background: #f3f3f3;
}
#sitecontainer {
width: 59.7em;
margin: 0 auto;
font-size: .9em; /*bring font-size smaller like you wanted*/
line-height: 1.3em;
}
#hours {
margin-left: 1.4em;
color: #8cc63f;
font-weight: bold;
}
#header {
width: 776px; /*setting a width in px because of img*/
min-height: 111px;
background: url(fmc_header.png) 0 0 no-repeat;
}
#header p {
min-height: 25px; /*size of divit in image*/
color: #404040;
font-weight: bold;
text-align: right;
}
#header ul {
list-style: none;
float: right;
width: 22em;
border: 1px solid #8dc640;
-moz-border-radius: .5em;
-webkit-border-radius: .5em;
border-radius: .5em;
}
#header li {
display: inline;/*this is pretty much to stop an IE bug, no other reason*/
}
#header a {
float: left;
width: 12.5em;
padding: 1.6em .5em;
color: #fff;
font-weight: bold;
text-align: center;
text-transform: uppercase;
text-decoration: none;
background: url(fmc_button.png) 0 0 repeat-x;
border-right: 1px solid #8dc640;
}
#header li+li a {
width: 7.3em;
border-right: 0;
}
#header a:focus, #header a:hover {
background-position: 0 -62px;
}
</style>
</head>
<body>
<div id="sitecontainer">
<p id="hours">OPEN M-F 8:30AM-5:30PM</p>
<div id="header">
<p>Serving our community for over 69 years.</p>
<ul>
<li><a href="latehours.php" class="latehoursbutton">Late Hours Clinic</a></li>
<li><a href="staff.php" class="staffbutton">Staff</a></li>
</ul>
</div>
</div>
</body>
</html>
http://stommepoes.nl/medical.html
Because of the em sizing, even this code results in small differences between browsers… how large the tagline is, the height of the buttons. I tried border-radius just to see if it could work ok… it’s not bad but would work better in px if it really needs to match that background image.
Also I put text in the buttons and styled them, since right now you have no button text. If the image doesn’t load for some reason, or the user can’t see images, those links are unknowns. I just threw in there a repeated png but the one you have has rounded corners… and you can see that is a small problem.
IE6 is not catered for in this code, mostly because in your version it looks like you’re supporting IE7 and above (I see nothing to fix the png issue… which, that image can be a flattened PNG instead of one with transparency… which brings the filesize down from 6.2kb to 2.9… nice).
If I were supporting IE6, every time I had “min-height” I would follow with a * html height declaration… and I would put a class on the second anchor in the nav so that I could style it as IE6 doesn’t recognise + selectors.
And, I probably would have a background image with rounded corners like you have, but then the buttons would HAVE to be sized in px, no other way around that.
But anyway, the above is an example to show how I see that content… another developer may do things quite differently. You could try something similar to mine.
So, general rule:
-text should be set in a flexible unit…em and % are recommended. I keep this simple to avoid weird inheritance problems (since an em is based on whatever 1em is of its parent… and I hate math).
-containers ideally would also be set in em’s or %, except where they must have px-based margins or padding (since trying to add those up is difficult to impossible)
-designs that are strongly image-based might not be able to have em-based containers unless there is a lot of sliding-doors (bits of images held at the corners of various elements to allow growing/shrinking boxes to maintain their overall look). Keeping the text flexible and the boxes in px to match background images means that while a bunch of text-enlargment might be okay (text grows, wraps, and ultimately gets “taller” on the page), eventually the text will be too large to fit in those px boxes and the design will break.
On that last note, in my designs I’m generally ok with design breaking if the text is still readable, since that’s ultimately the user’s goal, to read your page. But it does mean I check to see if, for example, light-coloured text falls out of a dark-coloured box and into a light area… I may have to give that text a background colour to keep contrast acceptable. Since this background-colour is invisible while the text is still contained inside the dark container, it’s win-win… but when there are gradients things start to suck : (