Background Repeat 1This is one example of how you can have a background image repeated down the page.This example shows a full image on either side of the page that is repeated downwards. <Table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td background="bgrepeat.gif" width="75"> </td> <td id="cell" valign="top" style="padding:5">Contents</td> <td background="bgrepeat.gif" width="75"> </td> </tr> </table> Each end cell has an image background with a fixed width denoted by the images width. As you add content to the center cell its height will increase, because the height of the outer cells will also increase this allows the image to repeat. To ensure you finish with a full image at the end of the page a script is used to do the following:
If an additional repeat of the image is required at the end of the page change the value of variable offset to suit.
<script type="text/javascript">
<!--
bgImage=new Image()
bgImage.src="bgrepeat.gif"
offset=0
function setSize(){
cellH=document.getElementById("cell").offsetHeight
imgH=bgImage.height
numOfRepeats=Math.ceil(cellH/imgH)
document.getElementById("cell").height=((numOfRepeats+offset)*imgH)+"px"
}
// add onload="setSize()" to the opening BODY tag
// -->
</script>
|