Home » Programming / Coding

Top and Bottom Gradient Background : CSS / HTML

13 December 2008 4,810 views No Comment

While working on a new project I got into this. I have to have a background on top and also at the bottom of the page. Nothing too difficult. Only problem was making it work on all browsers. When you minimize the browser window followed by a maximize browser window, some browsers seem to show the background color at the bottom instead of re-rendering the bottom to the browser window bottom. So this is what I came up with seem to work on all major browsers. I am using the code for one of my client’s website as well.

<html>
<head>
<style type=”text/css”>
html, body  {height:100%}
body {
margin:  0;
padding: 0;
color:  #000000;
background:  URL(images/page_bg.jpg) top left repeat-x #7C8FF7;
}
#bottom_gradient {
min-height: 100%;
height: auto !important;
height: 100%;
color:  inherit;
background:  URL(images/page_bg_bottom.jpg) bottom left repeat-x;
}
</style>
</head>
<body>
<div id=”bottom_gradient”>
test test test
<div style=”background-color:red;width:20px;height:400px;”>&nbsp;</div>
<div style=”background-color:blue;width:20px;height:40px;”>&nbsp;</div>
</div>
</body>
</html>

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.