I need some help with CSS: background...

User 2231947 Photo


Registered User
3 posts

Hi guys,

I'm relatively new to CSS programming and I need a hand. I decided to create a stylesheet from scratch to compliment fresh HTML for my company's website. I'll post the relevant code below (since the site has not gone live), but here's my issue:

I have a very simplistic fixed width, 3 column layout with both a header and a footer. In the left and right columns, I have specified a background image to repeat on the y axis, but the repeat will not go the full height of the page (which should be determined by the column div with the greatest height as I understand it). Instead, the repeats on both columns will only go as far as their respective content. I've been scouring the interwebs for solutions and comparing code against what I have determined by my layout; I've tried fixing heights to auto, to 100%, clearing floats, etc, nothing works. I've tested in both IE9 and FF5.

I would love to see the left and right column backgrounds extend all the way down to the footer. I can almost guarantee that the middle column content will be the highest.

And help would be greatly appreciated. Thanks.

-Steve

CSS

#container { margin; 0 auto; width; 1000px; background: #fff; }
#header { width: 1000px; background: #006400 }
#navigation { float: left; width: 1000px; background: #006400 }
#content-container { float: left; width: 1000px; background: #fff; }
#leftcol { float: left; width: 200px; padding: 10% 0; margin: 0; background-image: url('gradient1.jpg'); background-repeat: repeat-y; }
#content { float: left; width: 500px; padding: 5% 0; margin: 0; }
#rightcol { float: left; width: 300px; padding: 10% 0; margin: 0; background-image: url('gradient3.jpg');}
#footer { clear: left; background: #ccc; text-align: center; padding 0; height: 1% }


HTML

<body>
<div id="container">
<div id="header">
...
</div>
<div id="navigation">
...
</div>
<div id="content-container">
<div id="leftcol">
...
</div>
<div id="content">
...
</div>
<div id=rightcol>
...
</div>
</div>
<div id="footer">
...
</div>
</div>
</body>
User 2231947 Photo


Registered User
3 posts

Doh, I just noticed some syntax typos in the CSS, but the forums aren't letting me go back and edit the post. The coding was rewritten as I program on a different computer entirely, the same syntax errors present here are not present there.

My apologies. Here's the clean version:

CSS

#container { margin; 0 auto; width; 1000px; background: #fff; }
#header { width: 1000px; background: #006400; }
#navigation { float: left; width: 1000px; background: #006400; }
#content-container { float: left; width: 1000px; background: #fff; }
#leftcol { float: left; width: 200px; padding: 10% 0; margin: 0; background-image: url('gradient1.jpg'); background-repeat: repeat-y; }
#content { float: left; width: 500px; padding: 5% 0; margin: 0; }
#rightcol { float: left; width: 300px; padding: 10% 0; margin: 0; background-image: url('gradient3.jpg'); background-repeat: repeat-y; }
#footer { clear: left; background: #ccc; text-align: center; padding 0; height: 1%; }
User 2231947 Photo


Registered User
3 posts

Update

The best workaround I found was a javascript plug-in from dynamicdrive.com. It forces all of the columns to be the same size. (They set it up to work with their template coding, but they also instruct on how to do it with your homemade CSS coding.)

Relatively quick fix and from what I can tell the only pitfall is that the site will appear horrible with disabled javascript.

Is there a fix within CSS itself to maybe avoid that? I'm a huge fan of simple, clean code. But it's looking like there may not be an easy fix using CSS alone.
User 629005 Photo


Ambassador
2,174 posts

Steve wrote:
I've tested in both IE9 and FF5.


While 'probably' not really a cause of your particular problem... I would steer clear of "testing" in the newest versions UNTIL you know for a fact that your site looks like it should in the "popular" versions. FX5 just came out within the week, and although IE9 has been out a little longer, I don't trust it "enough" to rely on for testing.

JM3.5cents(inflation ya know) ;)
Living the dream, stocking the cream :D

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.