在javascript中获取用户屏幕大小,并将图像调整为临时文件,然后在后台加载


Get user screen size in javascript and resize the image into a temporary file and load it up in the background

.roof {
    background-image: url('roof.png');
    width: 100%;
    padding: 0 0 10% 0;
    position:absolute;
    top:0;
    z-index:500;
}

这里是php代码。

https://dl.dropboxusercontent.com/u/46431913/image.php

代码的问题是,它不能得到屏幕大小或div大小,我想我的图像适合。尺寸是固定的。如果你能给我一些建议就太好了。

您是否尝试过为您的图像使用background-size或max-width (inline) ?