I'd like a background image to repeat across the whole screen for a few sections of my site. I'd like the content to have a fixed width though. Normally I would have a nice wrapper class around the whole site, like this:
But normally the .wrapper would have a width of - say - 960px, which means my background images for the header, content and footer won't stretch the whole screen. This leads me to the rather messy markup:
Yeah, that would be fine if I just wanted to have one background image, but I'd like to have a background image for the header, a different one for the .content, and a different one for the footer! Dynamic sizes etc.
Ah yes, sorry - didn't read it close enough! In that case you'll have to get a little messy with the code and give a wrapper to each section to create the 100% width.
I think this is a clasic layout, as seen on many pages. If your content is centered on the page (wrapper) and you just want to extend the header to the left and to the right, just add a giant neagtive margin to both sides and the same amount as a positive padding.
body { overfow-x: hidden; }
header { margin: 0 -9999px; padding: 0 9999px; }
I'm not sure if this is the "best" way of doing it, but it always did the trick for me.
Yes, I thougt I've seen it here but I couldn't find it. Chris likes to do things with :before and :after nowadays. :) Maybe I should adopt some of his techniques.
, html 5 tags currently are not supported in all browsers, so you might just want to stick with the classice div id's (ex: ).
If you go with your original markup. Just go with in your CSS and mark it up simply:
header, footer, #content {background:#(color of choice) or (background image of choice, and just repeat it to your choice repeat-x or repeat-y); width:100%;}
.wrapper {width:960px;}
Very simple CSS and you can go with your original html markup. Hope this works out for you.
I'd like a background image to repeat across the whole screen for a few sections of my site. I'd like the content to have a fixed width though. Normally I would have a nice wrapper class around the whole site, like this:
But normally the .wrapper would have a width of - say - 960px, which means my background images for the header, content and footer won't stretch the whole screen. This leads me to the rather messy markup:
now the background images of header, .content and footer will stretch 100% of the whole page. The content of each part can be 960px.
Now my question:
Is there any neater way of doing this so I can keep my markup like I wrote first?!
Thanks guys! Dave.
Yeah, that would be fine if I just wanted to have one background image, but I'd like to have a background image for the header, a different one for the .content, and a different one for the footer! Dynamic sizes etc.
I think this is a clasic layout, as seen on many pages. If your content is centered on the page (wrapper) and you just want to extend the header to the left and to the right, just add a giant neagtive margin to both sides and the same amount as a positive padding.
I'm not sure if this is the "best" way of doing it, but it always did the trick for me.
Greetz.
But beware the browser support!
If you go with your original markup. Just go with in your CSS and mark it up simply:
header, footer, #content {background:#(color of choice) or (background image of choice, and just repeat it to your choice repeat-x or repeat-y); width:100%;}
.wrapper {width:960px;}
Very simple CSS and you can go with your original html markup. Hope this works out for you.