【发布时间】:2020-07-02 21:15:28
【问题描述】:
(注意:这是 [确切地] 1½ 年 前提出的,并且 [确切地] 零活动......我显然有同样的问题,所以希望 OP @Jaffa 不会介意我捎带它,并在它上面打赏以[希望]引起一些兴趣!)
OP 的原始问题是 below,而我添加的问题和示例是 below that。
[原问题:]
我正在尝试在 SVG 上制作缩小效果的动画。我已经让它工作了,但是第一帧,缩放到 30,在 Firefox 中是模糊/像素化的。
我在 Chrome 或 Edge 中没有看到同样的问题。初始帧很清晰,就像我期望的 SVG 一样。
html,
body {
margin: 0px;
padding: 0px;
}
.wrapper {
padding: 50px 50px;
max-width: 1200px;
margin-left: auto;
margin-right: auto;
margin-top: 80px;
}
.img_zoom {
width: 400px;
height: 500px;
margin: 2em auto 2em auto;
overflow: hidden;
}
.zoom {
width: 100%;
height: 100%;
background-position: center;
background-size: cover;
animation: zoom 5s ease-in-out 4s 1 normal forwards;
transform: translate(3400px, -3600px) scale(30);
}
@keyframes zoom {
to {
margin-left: 0;
transform: translate(0px, 0px) scale(0.7);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="wrapper">
<div class="img_zoom">
<div class="zoom"><img src="https://flexion.tech/images/box-con.svg"></div>
</div>
</div>
</body>
</html>
代码笔在这里供审核:
https://codepen.io/jaffa80/pen/KKpxgeQ
有什么办法可以解决 Firefox 中的模糊问题吗?
我遇到的另一个问题是,如果我从 @keyframe 中删除 margin-left:0 ,事情就会停止工作。对此的任何指示也将不胜感激。
编辑:
我有一个圆形 div 容器,其中包含几个元素以在圆圈内定位文本。当用户到达它时,我需要圆圈“增长”,所以我想我会使用 transform:scale() 与过渡或动画。
但是,仅在 Firefox 中,在过渡(或动画)完成之前,文本是模糊的。奇怪的是,圆圈的边界仍然非常清晰(我认为?)。
考虑到预渲染可能需要一点时间,我尝试单独使用 setTimeout 进行延迟,以及结合事件(open 和 DOMContentLoaded)和 requestAnimationFrame。我还尝试使用 css animation 而不是 transition。
在 Firefox 中似乎没有什么不同,但 Chrome 和 Edge 似乎还不错。是否有我不知道的 prefix,或者这可能是 Firefox 中的渲染 bug?
我的 MCSE 是 sn-p below:
setTimeout(function(){
circ.classList.remove('shrunk');
},500);
body{ font-family:'fira code'; font-size:20px; }
#circ{ position:relative; border:3px solid blue; border-radius:50%; text-align:center; white-space: nowrap; transition:transform 1000ms; }
#circ span{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); }
.shrunk{ transform:scale(0.1); }
<div class='shrunk' id='circ' style='width:336px; height:336px;'>
<span>Lorem<br>Ipsum is simply<br>dummy text of the<br>printing and typesetting<br>industry. Lorem Ipsum has<br>been the industry's<br>standard dummy text ever<br>since the 1500s, when an<br>unknown printer took a<br>galley of type and<br>scrambled it to make<br>a type specimen<br>book.</span>
</div>
有什么建议或解决方法吗?
【问题讨论】:
标签: css firefox css-animations rendering css-transforms