简体   繁体   English

为什么我的背景图片放大?

[英]Why does my background picture zoom?

I have some toggling journal entries and everything works okay except my background picture zooms in or out depending on which entry I am on. 我有一些切换日记条目,并且一切正常,除了我的背景图片根据我所在的条目而放大或缩小。 It seems that it zooms in more on the longer entries and zooms out on the shorter ones. 似乎它会在较长的条目上放大更多,而在较短的条目上放大。 The background is under the body tag in my CSS. 背景在我的CSS的body标签下。

Here's my background that's having problems. 这是我遇到问题的背景。

body {
background-image: url("http://housedivided.dickinson.edu/grandreview/wp-content/uploads/2010/02/HD_4USCinfantryDetail.preview.jpg");
background-size: cover;

} }

Here's my full code: http://jsfiddle.net/michaelpri/urz1sLa8/2/ 这是我的完整代码: http : //jsfiddle.net/michaelpri/urz1sLa8/2/

Any help is greatly appreciated. 任何帮助是极大的赞赏。

Try using contain instead of cover . 尝试使用contain而不是cover

When you click, the page height changes, and the background has to cover it all, so it zooms in. 单击时,页面高度会发生变化,背景必须覆盖所有内容,因此它将放大。

It's just how the background type acts. 这就是背景类型的作用方式。

Try to use background-size: 100% 100%; 尝试使用background-size: 100% 100%; , it will stretch the background to the screen size ,它将背景拉伸到屏幕大小

It zooms because the body size changes when you display these paragraphs under the menus. 之所以会缩放,是因为在菜单下显示这些段落时, body大小会发生变化。 If you make paragraphs the same size then it will probably stop zooming. 如果使段落大小相同,则它可能会停止缩放。 Or if you make them independent on the body. 或者,如果您使它们独立于身体。 Perhaps position: absolute will help. 也许position: absolute会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM