Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript更改背景大小_Javascript_Css_Jquery Mobile - Fatal编程技术网

使用Javascript更改背景大小

使用Javascript更改背景大小,javascript,css,jquery-mobile,Javascript,Css,Jquery Mobile,我在jquery mobile工作,我的背景是图像。由于手机屏幕大小不同,我的图像无法覆盖整个屏幕。只有在该脚本工作时才可能 document.getElementById("pageone").style.backgroundSize = screen.width+"px" screen.height+"px"; 但这不起作用您尝试过使用百分比宽度吗 我没有使用jQuery mobile,但我发现元标记对于响应式设计很重要:当然你可以用CSS来实现这一点 html { height:

我在jquery mobile工作,我的背景是图像。由于手机屏幕大小不同,我的图像无法覆盖整个屏幕。只有在该脚本工作时才可能

document.getElementById("pageone").style.backgroundSize = screen.width+"px" screen.height+"px";

但这不起作用

您尝试过使用百分比宽度吗


我没有使用jQuery mobile,但我发现元标记对于响应式设计很重要:

当然你可以用CSS来实现这一点

html { 
  height: 100%;
  background: url('../images/bg_cover_web.jpg') no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

我正在使用这个。这有助于提高身高,但不能覆盖整个宽度。请确保您使用的div是身高:100%;宽度:100%;