CSS:transform: translate(-50%, -50%) 使文本变得模糊 [英] CSS: transform: translate(-50%, -50%) makes texts blurry

查看:45
本文介绍了CSS:transform: translate(-50%, -50%) 使文本变得模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 div 居中,我使用这种方法,但它使 div 中的文本变得模糊:

I want to center my div and I use this method, but it makes my texts inside the div blurry:

<!-- language: lang-css -->

#div {
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

有没有办法让我的 div 居中?

is there any way to center my div?

推荐答案

在您要平移的元素块周围添加这些样式以修复抗锯齿,将 Z 轴平移为零值.

Add these styles around elements blocks which you are translating to fix the anti-aliasing, Translate Z-axis to have a zero value.

-webkit-font-smoothing: subpixel-antialiased;
-webkit-transform: translateZ(0) scale(1.0, 1.0);

这篇关于CSS:transform: translate(-50%, -50%) 使文本变得模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆