简体   繁体   English

Internet Explorer中的大型重复背景图片

[英]Large repeating background image in Internet Explorer

I'm trying to have an oversized image within a viewport container presented as a background image with a repeat style on it. 我正在尝试在视口容器中显示一个过大的图像,以背景图像的形式显示其上的重复样式。 The below code works for Chrome and Firefox, but when looking at it in Internet Explorer (observed in 9 and 11 on multiple machines), I'm getting an odd image tear of some sort. 下面的代码适用于Chrome和Firefox,但是在Internet Explorer(在多台计算机上分别以9和11观察)中查看它时,我得到了某种奇怪的图像。 Anybody have a solution? 有人有解决办法吗?

HTML: HTML:

<div class="map-layer"></div>

CSS: CSS:

.map-layer {
width:4468px;
height:2016px;
background: #000000 url('http://www.thormx.com/wp-content/themes/twentyeleven-child/rvmxgp-micro/images/world-map.png') 1px -1px repeat-x;
}

http://jsfiddle.net/75r8hgdg/1/ http://jsfiddle.net/75r8hgdg/1/

Note: When the background x position is set to 0, the tear effect disappears, but that defeats the purpose of starting at a specified (x,y). 注意:当背景x位置设置为0时,撕裂效果消失了,但这违背了从指定的(x,y)开始的目的。

It looks like the positive x position is causing the tear (very weird, most likely a bug) 看起来x位置为正正引起撕裂(很奇怪,很可能是个错误)

Try this instead: 尝试以下方法:

<style>
    .map {
        width:4468px;
        height:2015px;      
        padding-left: 1px;
    }
    .map-layer {
        width:4468px;
        height:2016px;
        background: url('http://www.thormx.com/wp-content/themes/twentyeleven-child/rvmxgp-micro/images/world-map.png') repeat-x #000000;
        background-position: 0 -1px;
    }
</style>

<div class="map">
    <div class="map-layer">
    </div>
</div>

After further searching, the solution I wound up using is referenced as a workaround in a different question found here . 经过进一步搜索后,我在这里找到的另一个问题中的解决方案被引用为我的解决方案。 By making the transparent image's height and width match, the artifacts go away. 通过使透明图像的高度和宽度匹配,伪影就消失了。

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

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