Stage 1: The image
Create a background for your website as you would normally. Our demonstration has a logo set in at the top as well as a graphic which needs to stay at the bottom of the page, and nice soft gradients and curves in between. Slice the image into 3 pieces: top, middle and bottom. The middle section should be no more than 1 or 2 pixels in height, this will be the part of the background that is repeated as much as required. Put the 3 images in your images folder.
Stage 2: The HTML
The code below is simplified for the purposes of this guide, our demo has extra divs for placing navigation, footers etc and we also used a partially transparent png for our content divs background to give a faded effect to the main background image.
<div id='site'>
<!-- The div for the top part of the background !-->
<div id='bg_top'>
</div>
<div id='main'>
<!-- Main site content goes here !-->
</div>
<!-- display bottom of background !-->
<div id='bg_bottom'>
</div>
<!-- Close site div !-->
</div>
Stage 3: The CSS
/* Puts the site in the middle of the page */
body{
text-align:center;
}
/* Ensures divs are shown same in all browsers */
div{
margin:0;
padding:0;
}
/* set middle background image as background, repeat vertically
* Make site appear in centre of page
* Z index ensures content in this div will show on top of other divs
**/
#site{
background-image:url(../images/bg_mid.jpg);
background-repeat:repeat-y;
text-align:left;
margin:auto;
width:800px;
z-index:3;
}
/** main content div, can be reposition to correct place on page **/
#main{
margin-top:-50px;
}
/** Display top part of background **/
#bg_top{
position:relative;
background-image:url(../images/bg_top.jpg);
background-repeat:no-repeat;
height:196px;
width:800px;
z-index:-1;
}
/** Display bottom part of background, top margin should be set to remove large space at bottom of page
* z-index is set so background does not cover up content
**/
#bg_bottom{
position:relative;
background-image:url(../images/bg_bottom.jpg);
background-repeat:no-repeat;
width:800px;
height:400px;
margin-top:-300px;
z-index:-1;
}
Conclusions
Blogger really isnt very good if you want to display html code in your blog! You need to convert the html entities (<, > and so on) first otherwise it just treats them as html. There are also all sorts of problems with sizing text, but enough about blogger! There are alternatives to the method described above, for example you could use a larger repeating image as the background and place your top logo and bottom graphic in separate divs over the top (using transparency in the images so that the background can be seen through them.
We will continue adding guides as and when we can, they will cover all aspects of web development from design to coding, databases to SEO and they will all be solutions to problems which we have discovered and used ourselves in our web work.