Very basic question!
I have a background pattern that repeats itself throughout the body tag. I would also like to have a top bar and bottom bar (head/footer) to repeat on the x axis - creating a nice sandwich style of solid color, pattern and solid color again for the background.
How can this be accomplished?
The bars need to be 100% width - which is why this isn't being done through the content wrapper or the header/footer div as they are set to 1000px wide. The color bars should go across the entire screen.
If you set the width to 100% on the body element you will have a full page width. This is essentially equivalent to not setting a width value and allowing the default. If you want to use the body element as a smaller container and let the HTML element fill the page, you could set a max-width value on the body.
The width property is used to fill a div remaining horizontal space using CSS. By setting the width to 100% it takes the whole width available of its parent. Example 1: This example use width property to fill the horizontal space. It set width to 100% to fill it completely.
You should:
html, body { margin: 0; padding: 0 }
#headerBar
and #footerBar
outside of your "content wrapper".Something like this: http://jsfiddle.net/GDDA5/
html, body {
margin: 0;
padding: 0
}
#contentWrapper {
width: 300px;
margin: 0 auto;
background: #ccc;
height: 100px
}
#headerBar {
height: 40px;
background: blue
}
#footerBar {
height: 40px;
background: red
}
Or if you would like the bars to stick to the viewport and be behind content: http://jsfiddle.net/GDDA5/3/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With