简体   繁体   English

非Webkit浏览器,旋转div中相邻图像之间的间隙

[英]Non-webkit browsers, gap between adjacent images that are in a rotated div

The goal is to rotate a div which is populated with "tiles" - which are adjacent image elements, with their locations set with the style properties top and left. 目标是旋转一个由“平铺”填充的div,这些平铺是相邻的图像元素,其位置设置为样式属性的顶部和左侧。

This works as expected in webkit enabled browsers (Chrome/Safari): http://jsfiddle.net/Yt99J/52/ 在启用了Webkit的浏览器(Chrome / Safari)中,此功能可以按预期工作: http : //jsfiddle.net/Yt99J/52/

<html>
    <head>
    <title>Rotating div of adjacent elements</title>
    </head>

    <body>
        <div id="canvas" style="overflow: visible; position: absolute; -webkit-transform: translate3d(0px, 100px, 0px) rotate3d(0, 0, 1, 0deg);">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 0px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 100px; left:0px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px;top: 100px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
        </div>

        <div id="canvas_rotated" style="overflow: visible; position: absolute; -webkit-transform: translate3d(400px, 50px, 0px) rotate3d(0, 0, 1, 45deg);">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 0px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 100px; left:0px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 100px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
        </div>
    </body>
</html>​

However, for non webkit browsers, when an image is rotated to an angle which is not a multiple of 90 degrees, there is a 1 pixel gap between tiles. 但是,对于非Webkit浏览器,当将图像旋转到不是90度倍数的角度时,图块之间会存在1个像素的间隙。 I'm assuming this is due to some rounding error at the lowest level inside the browser. 我假设这是由于浏览器内部最低级别的舍入错误所致。 Is there any way to work around this problem, other than scaling the tiles by a function of their size to make up the gap (I would like to avoid doing this if possible). 除了通过缩小瓷砖的大小来补偿空隙(是否可能这样做)以外,是否有其他方法可以解决此问题。 Here is an example of the bug, as implemented in FireFox: http://jsfiddle.net/Yt99J/50/ 这是在FireFox中实现的错误示例: http : //jsfiddle.net/Yt99J/50/

<html>
    <head>
    <title>Rotating div of adjacent elements</title>
    </head>

    <body>
        <div id="canvas" style="overflow: visible; position: absolute; -moz-transform: translate(0px, 100px) rotate(0deg);">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 0px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 100px; left:0px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px;top: 100px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
        </div>

        <div id="canvas" style="overflow: visible; position: absolute; -moz-transform: translate(400px, 50px) rotate(45deg);">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 0px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 100px; left:0px;" src="http://oi47.tinypic.com/15zjdky.jpg">
            <img galleryimg="no" style="display: block; position: absolute; width: 100px; height: 100px; top: 100px; left:100px;" src="http://oi47.tinypic.com/15zjdky.jpg">
        </div>
    </body>
</html>

To anyone that was wondering, looks like this is a quirk of some browsers. 对于任何想知道的人,看起来这都是某些浏览器的怪癖。 FireFox seem to be in the process of fixing this: https://bugzilla.mozilla.org/show_bug.cgi?id=504071 FireFox似乎正在解决此问题: https : //bugzilla.mozilla.org/show_bug.cgi?id=504071

Hopefully IE and other browsers follow suit. 希望IE和其他浏览器也能效仿。 This issue really sucks for mapping web apps. 这个问题对于映射Web应用程序确实很糟糕。

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

相关问题 非webkit浏览器的翻转卡效果 - Flip card effect for non-webkit browsers Angular JS和Bootstrap Multiselect Mixin在非Webkit浏览器上不起作用 - Angular JS and Bootstrap Multiselect Mixin not working on Non-webkit browsers 我应该依靠 CSS3 来获得 animation,还是使用 JavaScript 来造福非 WebKit 浏览器? - Should I rely on CSS3 for animation, or use JavaScript for the benefit of non-WebKit browsers? 用户进行文件更改(非Webkit浏览器)时,FileAPI不会更新文件大小 - FileAPI doesn't update the files size when user makes file changes (non-webkit browsers) 通过偏移量算术居中在非Webkit浏览器中不起作用 - Centering via offset math doesn't work in non-webkit browsers Android(非WebKit)的Javascript引擎选项 - Javascript engine options for Android (non-WebKit) 非 webkit rotateY animation 与 Jquery 的 Transform3d - Non-webkit rotateY animation with Jquery's Transform3d 如何通过JavaScript(非Webkit,非Next,版本14-)检测旧Opera。 - How to detect old Opera via JavaScript (non-Webkit, non-Next, version 14-) 使所有图像适合div中的间隙 - Fit all images with gap in a div Webkit浏览器:页面之间过渡时白色闪烁 - webkit browsers: white flashes on transitions between pages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM