Jquery 屏幕尺寸减小时自动调整图像大小

Jquery 屏幕尺寸减小时自动调整图像大小,jquery,html,css,Jquery,Html,Css,我用一个图像作为我的背景,它非常适合。 当我尝试调整屏幕大小(手机/平板电脑大小)时,图像会留在后面,不会像屏幕一样收缩,也不会变得灵敏。 我想改变这种效果,使它的反应,并成为更小的大小屏幕 见附件。 HTML: 尝试将宽度和高度调高,以使用vw和vh而不是%。另外,不要使用滚动作为背景图像属性上的位置,请使用“固定”。 我试过了 您还可以尝试在页眉div上使用绝对位置,并将边距设置为始终覆盖整个区域。我根据你的代码做了一个例子 您可以使用以下CSS代码: html { backgrou

我用一个图像作为我的背景,它非常适合。 当我尝试调整屏幕大小(手机/平板电脑大小)时,图像会留在后面,不会像屏幕一样收缩,也不会变得灵敏。 我想改变这种效果,使它的反应,并成为更小的大小屏幕

见附件。

HTML:


尝试将宽度和高度调高,以使用vw和vh而不是%。另外,不要使用滚动作为背景图像属性上的位置,请使用“固定”。 我试过了


您还可以尝试在页眉div上使用绝对位置,并将边距设置为始终覆盖整个区域。我根据你的代码做了一个例子


您可以使用以下CSS代码:

html { 
  background: url(img.png) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
从这里开始:


在提出问题之前,记得做些调查!在谷歌上快速搜索“css完整背景图像”会给你很多好答案。

不要在css中设置
宽度
高度
,而是添加
背景重复:无重复;背景尺寸:包含;背景位置:中心这种方法的优点是什么?这里有一些很好的答案。为什么不接受一个呢?我已经在我的应用程序中更改了它,但是在“检查”中,如果我将视图更改为移动/平板电脑视图,它会变小,并且不适合屏幕,如%.Hi,詹姆斯,我做了我的朋友,否则我不会问这个问题。你的意思是做了一些研究吗?因为你用的是“无重复中心滚动”,我用的是“无重复中心固定”。
/* Header */
.header {
    display: table;
    position: relative;
    width: 100%;
    height: 100%;
    background: url(../img/coffee.jpg) no-repeat center center scroll;
    color: #ffffff;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    background-size: cover;
    -o-background-size: cover;
}
.header {
  display: table;
  position: relative;
  width: 100vw;
  height: 100vh;
  background: url(http://lorempixel.com/1920/1080/food) no-repeat center center fixed;
  color: #ffffff;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  background-size: cover;
  -o-background-size: cover;
}
.header {
background: url(../img/coffee.jpg);
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
background-repeat:no repeat;
background-size:cover;
color: #ffffff;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
html { 
  background: url(img.png) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}