I have a cross-browser CSS gradient, such as this:
#background {
background: #1E5799; /* old browsers */
background: -moz-linear-gradient(top, #002c5a 0%, #79d6f4 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#002c5a), color-stop(100%,#79d6f4)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#002c5a', endColorstr='#79d6f4',GradientType=0 ); /* ie */
}
But I need it to span the height of the entire page, not just the viewport. In other words, I need to apply the style to an element that has the same height as the entire page, which would usually be body
or html
.
Further complications:
I'm also using the sticky footer, which requires html
and body
to be set to 100% height. So applying the style to them results in only the viewport being filled.
I'm not even sure if what I'm asking is possible, but any help would be appreciated.
you don't need a wrapper:
CSS:
sample HTML:
The gradient won't show if you don't have any content inside your divs! :) Hope this helps!
Another option if you want the gradient to scale ONLY to your viewport but be maintained when you scroll. So instead of the gradient plotting the entire height of the document it remains relative only to whats visible. (Try it out you will see what Im saying)
It will do the trick, the
min-height
property spans the total height even if the page is scrollable, but height property sets the height of active view-port as 100%.This works cross browser!
You could wrap the entire content of the page in a background div, then set it to that. This way the wrapping div will fill up with all your content and the background will expand across the whole page.
HTML:
CSS:
That should do it :)
Based on Kyle's solution, as well as the other styles from the sticky footer, here is the solution that finally worked:
With the following html: