Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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
Html CSS在缩小屏幕时是否保持背景不变?_Html_Css - Fatal编程技术网

Html CSS在缩小屏幕时是否保持背景不变?

Html CSS在缩小屏幕时是否保持背景不变?,html,css,Html,Css,因此,我有这样的背景: BODY { background-color: #FFFFFF; background-image: url(http://i42.tinypic.com/2gxn0gg.jpg); background-repeat: no-repeat; background-position: center; background-size: 100%; /* width, can be %, px or whatever. */; background-

因此,我有这样的背景:

BODY {
  background-color: #FFFFFF;
  background-image: url(http://i42.tinypic.com/2gxn0gg.jpg);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100%; /* width, can be %, px or whatever. */;
  background-size: 70% auto; /* height, can be %, px or whatever. */;
  background-attachment: fixed;
}


当我最小化屏幕(使其变小)时,我希望它保持紧贴顶部,或者保持最大化时的大小。我该怎么做?有什么想法吗?

不要使用
背景大小
,除非您确实想更改背景大小。您告诉它根据
主体的大小改变背景的大小:当您使窗口大小变小时,主体的大小会改变


在您列出的描述中,您可以使用“%,px,随便什么”,但它们实际上做不同的事情。“%”是动态的,这意味着它受屏幕大小或浏览器窗口的影响。另一方面,“px”是静态的,无论屏幕大小如何都不会改变


因此,如果不尝试更改图像的大小,则不应使用“%”。使用像素。

使用
宽度:自动安装
背景大小

 BODY {
background-color: #FFFFFF;
background-image: url(http://i42.tinypic.com/2gxn0gg.jpg);
background-repeat: no-repeat;
background-position: center; 
width:auto; 
 }

这是

你的小提琴坏了~哦,嘿,又是你~而且。。。如果我取出背景尺寸,那么我如何将其设置为我喜欢的尺寸,因为这不是图像的实际尺寸?哈哈,又是:)哦,那么你是在使用
背景尺寸
将图像拉伸到你喜欢的尺寸,你只是不想随着窗口尺寸的改变而改变?您可以使用
px
而不是
%
来设置它,然后它将保持不变。但是,您可能应该使用更大的图像?为了图像质量,我花了很长时间制作动画,所以。。。不:p,我没有得到新的图像。但是,我使用的是px而不是%,其他人给出了答案。谢谢:3。
 BODY {
background-color: #FFFFFF;
background-image: url(http://i42.tinypic.com/2gxn0gg.jpg);
background-repeat: no-repeat;
background-position: center; 
width:auto; 
 }