Even the mods run into a wall sometime

Okay guys, I’ve run into something of a snag here. I’m building this non-profit org a site pro bono, based on a template the organization owner wanted to use. I’ve run into two related snags.

Mother Hubbard’s Cupboard

Both problems are related to that <h1> taking up more real estate than it should. The logo should be a clickable link, and it is, but only in FF – not Opera or Chrome. And to get the subheading “feeding wilmington’s hungry” to position properly, I used a brute-force “position: absolute” solution which I really don’t like. Any thoughts?

The site’s still rough; that top-right pic, for example, is just a placeholder and isn’t aesthetically optimized with blended edges and so forth. And the logo is a trainwreck, but it’s what the owner wants to use (and even bigger, in all its pixelated glory!). I also haven’t gone through and weeded out the instances of divitis yet. Even so, if you see something else wonky, don’t hesitate to point it out.

For the few posters who may be laboring under the delusion that all the mods know more code/design techniques than the posters, let this be a teachable moment for ya. :slight_smile:

Thanks, everyone.

The reason for the logo not been click-able is because you set a line-height at an earlier point in the CSS which is rendering the anchor as an inline element rather then a block level element. To fix this you can simply add the following to your #slogan > a selector which will change it back to a block level element.

#slogan > a {
    display: block;
}

As to why the H1 element is taking up the entire parent container i would say its just the native browser inheritance taking over, if you give it a set width and height that should resolve the issue.

For the few posters who may be laboring under the delusion that all the mods know more code/design techniques than the posters, let this be a teachable moment for ya. :slight_smile:
Happens to everyone, no one person knows everything which is why we are all here on this site in the first place :slight_smile:

Thanks Sarge, I will give that a whirl tomorrow after I’ve had some sleep. Should have known it was something “simple”; those are what always get me. I started learning code on SP while I was still coding with tables and <center> tags (but thankfully after I stopped using the <marquee> tag and such). No one knows everything about it all.

Okay, I’m lying, it’s after 4 am and I just have to check it before I hit the hay. And…the link is now clickable. :slight_smile: Aside: I’m thinking more of setting a max-width and max-height on the <h1> instead of a specific width/height. Any issues you can see with that? It’s awfully late and I’m bleary, but I seem to remember some IE issue.

The main issue with using min and max in CSS is that IE 6 & 7 don’t know how to read it, a nice work around i use is some simple jQuery to collect the total width of the parent element for example by jumping through all the child elements and incrementing the value onto a var outside the loop. When its done i then use one more line to set the width and all works well in IE 6 & 7.

I would probably have done the whole logo and tagline as one gilder levin image replacement floated left (and lose the cufon).


 <h1><a href="#">Mother Hubbards Cupboard  <small>Feeding wilmingtons hungry since 2010</small><span></span></a></h1>

And then float the donate to the right with the two kids as a background image to the donate button. That gets the header down to 2 simple elements

Or alternatively with browser text something more complex like this.


<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
    max-width: 1400px;
    min-width: 900px;
    position:relative;
}
#header {
    height:263px;
    padding:0 0 50px;
    overflow:hidden;
    position:relative;
    border-bottom:10px solid #ccc;
    white-space:nowrap;
}
h1 {
    float:left
}
h1, h1 a, h1 span {
    width:256px;
    height:226px;
    overflow:hidden;
    margin:0;
    position:relative;
    cursor:pointer;
    white-space:normal;
}
h1 span {
    position:absolute;
    top:0;
    left:0;
    background:#fff url(http://www.iraqtimeline.com/mhc/img/mhclogosm.gif) no-repeat 0 0;
}
p.donate {
    position:absolute;
    right:0;
    top:0;
    padding:242px 0 0 0;
    width:220px;
    background:url(http://www.iraqtimeline.com/mhc/img/twokids.jpg) no-repeat 0 0;
}
p.donate a {
    display:block;
    background:red;
    width:220px;
    height:54px;
    line-height:54px;
    color:#fff;
    text-decoration:none;
    text-align:center;
}
p.tagline {
    display:inline-block;
    vertical-align:middle;
    color:green;
    font-size:220%;
    margin:0 550px 0 0;
    white-space:normal;
}
p.tagline span {
    display:block;
    font-size:60%;
    color:#000;
}
.push {
    display:inline-block;
    vertical-align:middle;
    width:1px;
    overflow:hidden;
    height:100%;
    margin-right:-5px;
}
* html p.tagline, * html .push {display:inline}/* ie6 inline-block fix*/
*+html p.tagline, *+html .push {display:inline}/* ie7 inline block fix*/
* html p.tagline {margin-right:260px}
*+html p.tagline {margin-right:260px}
</style>
</head>
<body>
<div id="header">
    <h1><a href="#">Mother Hubbards Cupboard - help hope humanity <span></span></a></h1>
    <p class="tagline">Mother Hubbards Cupboard with some more text <span>Feeding wilmingtons hungry since 2010</span></p>
    <p class="donate"><a href="#">Donate</a></p>
    <div class="push"></div>
</div>
</body>
</html>


Paul is right on the tagline bit – you’ve got paragraphs around non-paragraph elements, fixed height containers with dynamic fonts in them (shtups your whole layout on large font machines), Looks like a few more DIV than should be necessary, , classes on things that shouldn’t probably have classes (though much of that is for the broken/bloated scripting), jquery bloat for christmas only knows what, that outdated cufon nonsense that we can finally STOP wasting time on thanks to @font-face now being cross-browser, comment placement that could be tripping rendering errors (yes, COMMENTS), and of course since you seem to have some bits of YUI in there too, you’ve doubled your bloat.

Much less sending the same style to screen and print (with no projection or TV?!?) declaring a robots that’s identical to the defaults (at which point dont’ waste time on it), sending a type with the .ico while omitting a type on the .png (that’s actually backwards), or the completely pointless/redundant title attributes on the menu – title=“link”? Oh yeah, that’s real useful… Oh, and might help if your indentation made the least bit of sense. I could go on for quite a bit on this… and that’s without even talking about a fluid layout that breaks below 1024 (at which point why bother?)

I mean, you’re at half a megabyte for three content images, some tileable backgrounds, and 1.3k of plaintext?

So first order of business? Cleaning up the HTML – CSS is only as good as the HTML it’s applied to. If I was writing that I’d gut the markup down to this, axing all the javascript for nothing nonsense:


<!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"
/>

<meta
	http-equiv="Content-Language"
	content="en"
/>

<link
	type="text/css"
	rel="stylesheet"
	href="screen.css"
	media="screen,projection,tv"
/>

<link
	rel="shortcut icon"
	href="favicon.ico"
/>

<link
	rel="apple-touch-icon"
	type="image/png"
	href="apple-touch-icon.png"
/>

<title>
	Mother Hubbard's Cupboard
</title>

</head><body>

<div id="heightWrapper">

	<ul id="socialLinks">
		<li>
			<a href="#" title="MHC for Your Phone">
				<img src="http://www.sitepoint.com/forums/images/mobileIcon.png" alt="Mobile Phone" />
			</a>
		</li><li>
			<a href="#" title="MHC on Facebook">
				<img src="http://www.sitepoint.com/forums/images/facebookIcon.png" alt="FaceBook" />
			</a>
		</li>
	</ul>

	<h1>
		<a href="/">
			Mother Hubbard's Cupboard<br />
			<small>
				feeding wilmington's
				<span>hungry since 2010</span>
			</small>
		</a>
	</h1>

	<div id="topDonate">
		<a href="#"><span>Please Donate and Help the Hungry Today!</span></a>
	</div>

	<ul id="mainMenu">
		<li><a href="/">Home</a></li>
		<li><a href="#">About</a></li>
		<li><a href="#" class="current">Donate</a></li>
		<li><a href="#">Volunteer</a></li>
		<li><a href="#">Newsletter</a></li>
		<li><a href="#">Contact</a></li>
	</ul>

	<hr />

	<div id="callToAction"><div class="widthWrapper">
			<div class="ctaText">
				<h2>Helping Those in Need</h2>
				<p>
					Serving Wilmington&rsquo;s hungry by distributing emergency food supplies to those in need without regard to race or religion, and always mindful of the dignity of those we assist.
				</p>
				<a href="#" class="readMore">
					Why our aid is so critical...
				</a>
			<!-- .ctaText --></div>
	<!-- .widthWrapper, #callToAction --></div></div>

	<hr />

	<div id="content" class="widthWrapper">
		<h2>
			News, Time-Critical Information, or Points of Emphasis
			<small><span>-</span> March 1, 2011</small>
		</h2>
		<p>
			Here you will put news items (i.e. announcing a new fundraising drive, a new initiative, an expansion in services, a new major donor, whatever), or time- or mission-critical information. The date above is optional for inclusion.
		</p><p>
			Duis aute irure dolor in reprehenderit in voluptate. <a href="#">Link to more information</a>.
		</p>
			
		<hr />

		<h2>
			News, Time-Critical Information, or Points of Emphasis
			<small><span>-</span> February 10, 2011</small>
		</h2>
		<p>
			Here you will put news items (i.e. announcing a new fundraising drive, a new initiative, an expansion in services, a new major donor, whatever), or time- or mission-critical information. The date above is optional for inclusion.
		</p><p>
			Duis aute irure dolor in reprehenderit in voluptate. <a href="#">Link to more information</a>.
		</p>
		
		<hr />
		
		<h2>Add more sections as desired.</h2>
		<p>
			Duis aute irure dolor in reprehenderit in voluptate. <a href="#">Link to more information</a>.
		</p>
		
		<hr />
		
	<!-- #content --></div>
	
<!-- #heightWrapper --></div>	

<div id="footer">
	2011 &copy;
	<a href="index.html">mother hubbard's cupboard</a>
	<ul>
		<li><a href="design.html">design info</a></li>
		<li class="last">valid html and css</li>
	</ul>
<!-- #footer --></div>

</body></html>

Basically throwing 1k of it away (excuse the XHTML, it’s what I do)

Gimme a few minutes I’ll bash out the CSS to go with that and toss it on my server as a demo… probably neuter down the images too as there’s no reason for that to be using more than 48-50k of images.

Few minor changes after styling, nothing major.
Mother Hubbard’s Cupboard

Wasn’t sure what to do with that donate button – it really doesn’t look good ANYPLACE above the menu; I’d be tempted to move that up into the same bar as the social networking links, just on the opposite side.

… and cuts the entire thing down to 41k (not counting fonts)… works fine in all modern browser, IE doesn’t get the glow effects on hover (oh noes) and apart from the lack of the CSS3 effects it works just fine all the way back to IE 5.5, and is even usable in IE 5.01.

Biggest savings came from axing that massive “for nothing” shadowed alpha png, and making a flat .jpeg out of it and applying the extra styling with CSS3. Oh noes, doesn’t work in IE8 or lower. OH WELL. I wouldn’t even waste time on a shiv for that.

Switching it to webfonts is MUCH more reliable than cufon – especially since it gets rid of all that scripting.

As with all my examples the directory:
Index of /for_others/blackMax

Is nice and open for easy access.

I also made it semi-fluid to an extent – the max width on the content area being in EM so that it will give a larger max width for large font users… and gave it a min-height layout to boot. Basically 2/3rds the HTML, 2/3rds the CSS, no scripting, and 17% the total image sizes.

Oh noes, it loses the fade in on link hovers (but gains glow) and the styled tooltips (that if neccessary probably means there’s something WRONG with the content of your anchors).

I’d probably consider making all those H2 be the links to the article in addition to a separate “read more” – and if you have “read more” links (which are usually frowned upon) put titles on them identical (or with some text before it like “read more about…”) to the H2 content.

The call to action area I switched to dynamic height, meaning it needed a taller background image. I add that image in the CSS instead of the HTML making it easy to change the vertical position to center as the height of that area changes when the width, height or font-size changes.

Hope this helps :smiley:

– edit – P.S. The flexibility of the model used to build it would make a mobile.css using a media query really easy to implement.

You guys rock the house. As Jason notes, there are a lot of blunt-force “fixes” in the code. I can blame some of it on the template, but I shoveled in my own gunk to add to the situation. Can’t wait to get in there and start dissecting the goodies. Jason, Paul, everyone, thanks!

for laughs I threw a simple sub<800 mobile stylesheet on it. You can test it in Opera/FF/Chrome by just setting your screen width narrow. Min-width of 296 and max-width of 608. Strips all the presentational images so that phone users don’t kvetch about it chewing bandwidth.

Looks good in the iphone sims.

I haven’t experimented much with it – domestic duties intervened, including wrangling cats while we did a massive grocery run – but I will give the mobile sim a run later this evening.

I’ve never been fond of the “glow” effect, but it looks good in the mockup.

Probably my biggest problem with the entire project was my approach. I’ve preached, and even written about, taking pro bono projects as seriously as you would any other project. However, because of a list of reasons mostly too petty to go into, I didn’t – instead I worked at it piecemeal, tossing in whatever quick and dirty “fixes” and components I could while focusing on something else. (Hence the Cufon, for one example – that was a five-minute add-on. I knew going the @font-face route was a more solid approach, but I had the Cufon files and everything together, so I just rammed it in there and went on.). It was a bad way to approach a project, and I’d better have learned something from the process.

This was awesome, Jason. Come down south sometime and Mrs. Max will make you barbecue. :slight_smile:

I have to agree that is very good work and looks good on small windows also with the mobile stylesheet applied.:slight_smile:

It’s a fascinating learning experience. I’m combing through the code going, “Okay, I see this … this is nifty … what the hell is this? How did he …?” I was so intent on it last night that I think my wife thought I was downloading, uh, other things.