Hi, everyone. I've just finally adjusted the way that the background images is laid out. my problem is that the image seems to load in original size and
then align to the screen's width.
I'm using a javascript code that I got from
http://stackoverflow.com/questions/1...g-aspect-ratio and it is working the way I want it to, mostly.
My problem is that I'm not sure how to keep the image from exceeding 100% height of the windows without squashing the aspect ratio?
I also need to figure out how to fix the visible action of the image being loaded in it's original size? If we can't get the image to load WHILE at the size I want it to be, can we at least 'hide' the image until the loading have been done?
I tried to tweak the codes to include the height limitation but it did not seem to have made any differences. This is my first time actually using javascript so please be easy on me, heh
My site is at
http://www.lost-ear-studio.com (if you refresh the site, you will see random background images being swapped out using php).
Code:
<script>
function resizeToMax(id){
myImage = new Image()
var img = document.getElementById(id);
myImage.src = img.src;
if(myImage.width > myImage.height){
img.style.width = "100%";
} else {
img.style.height = "100%";
}
}
</script>
Code:
<img id="bg" src="randombg.php" onload="resizeToMax(this.id)">
Code:
#bg{
position:fixed;
left:0px;
top:0px;
z-index:-1;
}