Hi.
So i'm building a pretty basic site for my sister. I have a image of a light gradient which i repeat horizontally. it's white at the top and about 500 px tall. My plan was to have it repeat along the bottom of my site, the empty space above it white. I positioned my background image like so in my CSS.
Code:
body {
line-height: 1;
background-image:url('images/background.jpg');
background-repeat:repeat-x;
background-position:bottom;
}
This does not work, instead of putting the image at the absolute bottom of the page, it goes to the bottom of where my content is, which means people with different resolutions will see a big gap beneath it.
other info, i'm using a reset see below, do i need to change something in this to make it work?
Code:
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
}
body {
line-height: 1;
background-image:url('images/background.jpg');
background-repeat:repeat-x;
background-position:bottom;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
Thanks in advance
Last edited by henrycooke; 01-03-2010 at 09:37 PM..
I don’t particularly like these default reset styles (and I also remember reading that they shouldn’t be used in their default state in every case as you might not want all styles reverted) but anyway: The body element actually is just an element like any other HTML element. It is a little special but basically it adapts to the content just as divisions or any element.
I’ve read somewhere a long time ago that the correct way in XHTML to specify a page background is to apply bg color and/or image to the html element, not to the body (as the body doesn’t automatically take 100% height).
Well, OK, you also need to set the height of the html element to 100% explicitly. That was the next guess I would have taken.
I’d recommend to use the shortcut:
Code:
html {
background: white url(images/background.jpg) bottom left repeat-x;
height: 100%;
}
And if you just have a simple gradient then I’d suggest you make it a PNG (24 bit). That’s better quality