简体   繁体   English

缩小时,重复y背景图像消失/不对齐

[英]A repeat-y background-image disappears/misaligns when zooming out

The image disappears when zoomed out to 40% on Firefox. 在Firefox上缩小到40%时,图像会消失。 Up until zoom 50%, it is fine. 直到缩放50%,它很好。 However at zoom 40%, it just vanishes: 然而,在缩放40%时,它只是消失了: 缩放比较Firefox

Whereas in Chrome the image is still visible but slightly misaligned, this happens at different levels of zoom: 在Chrome中,图像仍然可见,但稍有不对齐,这种情况发生在不同的缩放级别: Chrome错位

For once Internet Explorer is actually displaying the expected result regardless of zoom! 一旦Internet Explorer实际显示预期结果,无论缩放!

What is trident doing differently to webkit and gecko , and how can I patch it? 什么是三叉戟对webkit和gecko采取不同的做法 ,我该如何修补它?

Here is all the relevant code: 以下是所有相关代码:

 body { background-color: rgba(31, 59, 8, 1); } #main { z-index: 1; position: absolute; top: 113px; left: 50%; width: 900px; height: 100%; margin-top: 160px; background-image: url('http://i.stack.imgur.com/zZCB2.png'); background-repeat: repeat-y; margin-right: -50%; text-align: center; transform: translateX(-50%); } #main:before { content: " "; position: absolute; left: 0px; top: -113px; background-image: url('http://i.stack.imgur.com/7DE7i.png'); background-repeat: no-repeat; width: 900px; height: 113px; } #main:after { content: " "; position: absolute; left: 0px; bottom: -200px; background-image: url('http://i.stack.imgur.com/DVJAq.png'); background-repeat: no-repeat; width: 900px; height: 200px; } 
 <div id="main"></div> 

Making your body.png image 20px tall or so will fix the issue. 使你的body.png图像高20像素左右将解决问题。 1px repeating images act strange sometimes. 1px重复图像有时会很奇怪。 Should help with redraw/flickering while the element is loaded as well. 在加载元素时应该有助于重绘/闪烁。

Also, setting the "#main:before" to have a top of -112px instead of -113px got rid of the funky line in Chrome when you zoom in (at least for me). 此外,将“#main:before”设置为顶部-112px而不是-113px时放大Chrome中的时髦线(至少对我而言)。

Hope that helps. 希望有所帮助。

I am not sure, but i belive if you split the images and make 3 parts: ::before (white top, with bottom shadow) ::header (the red box) ::after (White bottom, with top shadow from the red box) 我不确定,但我相信如果你拆分图像并制作3个部分::: before(白色顶部,底部阴影):: header(红色框):: after(白色底部,顶部阴影来自红色框)

I hope that this answer helps! 我希望这个答案有所帮助!

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

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