S
Seige
Ever had headache when you can't resize the background width using CSS:
body{
background: url(/images/bg.jpg) ;
background-width: 800px;
}
It won't work, would it? Of course not, it's not even defined in CSS.
So, let's try to work it out using Javascript:
There are two methods, first method you prepare plenty of different
width images, classifying them into 640, 800, 1024, 1280, 1600 and
whatever other sizes. Then you use javascript to detect screen width
and you're done. Easy but not exactly what I'm looking for.
Second method: create a layer (for the background image) to go beneath
the existing content and resizing the image according to the screen
width.
bgimg = document.createElement("bgimg");
bgimg.src = "/images/bg.jpg";
st = {
position:"absolute",
zIndex:"-10",
width:screen.width,
top:"0",
left:"0"
}
for( s in st ){
img.style = st;
}
document.body.appendChild(bgimg);
body{
background: url(/images/bg.jpg) ;
background-width: 800px;
}
It won't work, would it? Of course not, it's not even defined in CSS.
So, let's try to work it out using Javascript:
There are two methods, first method you prepare plenty of different
width images, classifying them into 640, 800, 1024, 1280, 1600 and
whatever other sizes. Then you use javascript to detect screen width
and you're done. Easy but not exactly what I'm looking for.
Second method: create a layer (for the background image) to go beneath
the existing content and resizing the image according to the screen
width.
bgimg = document.createElement("bgimg");
bgimg.src = "/images/bg.jpg";
st = {
position:"absolute",
zIndex:"-10",
width:screen.width,
top:"0",
left:"0"
}
for( s in st ){
img.style
}
document.body.appendChild(bgimg);