CSS 变换 - 元素缩放但不翻译

洛夫罗·米尔尼克

我的 index.html 页面上插入了一个视频元素:

<body>
    <video id="animation" autoplay loop>
        <source src="animation.mp4" type="video/mp4">
        <source src="animation.webm" type="video/webm">
    </video>
    <script>
        scaletranslate();
    </script>
</body>

在我的 CSS 表中,我只是简单地定位视频:

body {
    margin: 0px;
    padding: 0px;
    overflow: hidden;
}
video {
    position: absolute;
    top: 0px;
    left: 0px;
}

而 Javascript 的scaletranslate()功能是:

document.getElementById("animation").style.transform = "translateX(250)";

但是,如果我使用以下代码,视频不会按原样移动:

document.getElementById("animation").style.transform = "scaleX(0.2)";

然后视频确实得到缩放。

为什么元素没有随着变换平移操作而移动?

约翰内斯

添加像素单元:

translateX(250px)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章