我有这个随机显示背景图像的代码。我调整了图像大小并降低了字节以降低加载速度。但是,我希望图像可以根据屏幕尺寸调整大小。
<script type="text/javascript">
var randnum = Math.random();
var inum = 3;
var rand1 = Math.round(randnum * (inum - 1)) + 1;
images = new Array();
images[1] = "bgImages/Blue_Venetian_Glass.jpg";
images[2] = "bgImages/Etched Glass.jpg";
images[3] = "bgImages/glass.jpg";
images[4] = "bgImages/Raindrops_on_Glass.jpg";
var image = images[rand1];
document.body.style.background = 'url("' + image + '") no-repeat center center fixed';
</script>
我的问题是“我需要什么来拉伸图像”