T
themasterrocker
Guest
Hi,
This might sound like im havin a laugh but
How do i change my background to a picture i got?
This might sound like im havin a laugh but
How do i change my background to a picture i got?
<body style="background-image:url('path to image');background-size: 100%;">
#divbg {
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
z-index: 0; <------------Notice!
}
#maincontent
{
z-index:1; <--------------Notice!
position:absolute;
}
<div id="divbg"><img src="http://www.powertunezfm.pcriot.com/BACKGROUND.gif" width="100%" height="100%"/></div>
<div id="maincontent"></div>
#divbg {
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
z-index: 0;
background:url("http://www.powertunezfm.pcriot.com/BACKGROUND.gif");
}
#maincontent
{
z-index:1;
position:absolute;
}
body {
background-image: url('http://www.powertunezfm.pcriot.com/BACKGROUND.gif');
background-repeat: no-repeat;
background-position: center;
background-color: blue;
cursor: hand;
scrollbar-arrow-color: blue;
scrollbar-base-color: blue;
scrollbar-dark-shadow-color: blue;
scrollbar-track-color: blue;
scrollbar-face-color: blue;
scrollbar-shadow-color: blue;
scrollbar-highlight-color: blue;
scrollbar-3d-light-color: blue;
}
function CreateBackground() {
bgimg = document.createElement("bgimg");
bgimg.src = "/images/bg.jpg"; //REPLACE THIS WITH THE PATH TO THE BACKGROUND IMAGE
st = {
position:"absolute",
zIndex:"-10",
width:getDocumentWidth(),
top:"0",
left:"0"
}
for( s in st ){
img.style[s] = st[s];
}
document.body.appendChild(bgimg);
}
function getDocumentHeight() {
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
return window.innerHeight
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
return document.documentElement.clientHeight
}
// older versions of IE
else
{
return document.getElementsByTagName('body')[0].clientHeight
}
}
function getDocumentWidth() {
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined')
{
return window.innerWidth
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
return document.documentElement.clientWidth
}
// older versions of IE
else
{
return document.getElementsByTagName('body')[0].clientWidth
}
}
...
<body onload="CreateBackground();">
...
function imageResize($width, $height, $target) {
if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = ($target / $height);
}
return “width=\”$width\” height=\”$height\””;
}
?>
The Function in Action
//get the image size of the picture and load it into an array
$BACKGROUND = getimagesize(”http://www.powertunezfm.pcriot.com/BACKGROUND.gif”);
?>
<img src=”http://www.powertunezfm.pcriot.com/BACKGROUND.gif” >