html - CSS 位置 :relative and -webkit-transform creates text weight glitch

标签 html css webkit webkit-transform text-width

当一个 CSS 动画被触发并且一个对象被 CSS 定位为除 static 之外的任何东西时(relativeabsolute 等)在动画持续期间,对象内的文本突然变得非常细。然后它会恢复为全宽。

尝试在 Safari 中运行此页面:http://pastehtml.com/view/bjgaloxjj.html (为澄清而更新)

请注意,当 #content div 不是绝对定位或相对定位时,问题就会消失。这是针对 iPad 网络应用程序的,在设备上比在桌面上更明显。

关于造成这种干扰的原因有什么想法吗?

编辑澄清:webkit-transformwebkit-transition 必须使用,因为它们是硬件加速的,这会导致更流畅的动画。

最佳答案

我能够重现您的问题并修复了它。您不需要transform 来获得您正在寻找的结果,只需要一个transitiontransition 本身是硬件加速的。

来自 http://www.html5rocks.com/en/tutorials/speed/html5/#toc-hardware-accell :

CSS Transitions make style animation trivial for everyone, but they also are a smart performance feature. Because a CSS transition is managed by the browser, the fidelity of its animation can be greatly improved, and in many cases hardware accelerated.

演示:http://jsfiddle.net/ThinkingStiff/bqSJX/

脚本:

function doMove() {
    document.getElementById('mover').style.left = '150px';

    window.setTimeout( function() {
        document.getElementById('mover').style.left = '50px';
    }, 1000 );

}

window.setInterval( function() { doMove(); }, 3000 );

CSS:

#content {
    font-size: 150%;
    position: relative;   
}

#mover {
    font-size: 200%;
    left: 50px;
    position: absolute;
    top: 250px;
    transition: left 1.1s ease-in-out;
}

HTML:

<div id="content">A large cake with seventeen BURNING candles is in the
    center of the table. It says "HAPPY 16TH BIRTHDAY" and
    "GOOD LUCK, WESLEY." The whole BRIDGE CREW waits
    around the table as Wesley ENTERS with Beverly. He's
    touched, embarrassed and -- wants to get out of there.</div>
<div id="mover">SOMETHING</div>

关于html - CSS 位置 :relative and -webkit-transform creates text weight glitch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8707212/

相关文章:

html - 如何获取HTML元素的位置信息

javascript - 绝对对齐列中元素的顶部

webkit - 用于滚动代码的 CSS 标记

html - 浏览器调整大小时布局中断

html - margin css 属性的特殊行为

css - Webkit 中的自动轮廓是什么?

html - 对包含 span 的 div 使用 float right 时没有右边框?

html - 为什么 Bootstrap 列与固定 header 重叠?

javascript - JS : Onchange event activated at startup

css - WebKit 中不稳定的 CSS3 宽度转换