[英]Css translate 50% on odd width/height blurring background image
I'm working on aa div which has odd width/height
and I need to transform it 50%, this blurs out my background image. 我正在使用具有奇数width/height
div,我需要将其变换50%,这会使背景图像变得模糊。 Is there a way to fix it? 有办法解决吗?
I have tryed to: 我试图:
scale(2)
and zoom(.5)
, but this gives me an issue when i move the component. scale(2)
和zoom(.5)
,但这在我移动组件时给了我一个问题。 backface-visibility: hidden;
or -webkit-font-smoothing: subpixel-antialiased;
或-webkit-font-smoothing: subpixel-antialiased;
, but this only fixes the text inside the div if it is blurry. ,但这只会在div内的文本模糊时对其进行修复。 filter: blur(0)
perspective(1)
or removing a single pixel from width/height would be a hack more than a solution. 使用诸如perspective(1)
类的技巧或从宽度/高度中删除单个像素将比解决方案更有效。 <div class="my-div any-other-random-class"/>
// CSS
.myclass {
transform: translate(50%, 50%);
}
.any-other-random-class{
width: 123px;
height: 111px;
}
I expect the background image not to be blurry, but it is blurry due to translate
calculating a decimal value. 我希望背景图像不会模糊,但是由于translate
计算十进制值而导致模糊。
Edit: I have noticed this appening only on chrome. 编辑:我注意到这只适用于chrome。
Try this, it worked for me. 试试这个,对我有用。
transform: translateZ(0) translate(50%, 50%);
backface-visibility: hidden;
-webkit-filter: blur(0);
filter: blur(0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.