css 模糊了 chrome 中的框边框

The css blurs the box border in chrome

提问人:Zhiqiang Du 提问时间:11/13/2023 最后编辑:Hao WuZhiqiang Du 更新时间:11/13/2023 访问量:117

问:

enter image description here

body {
  font-family: sans-serif;
}
p {
  column-fill: balance;
  column-count: 2;
}

.box {
  width: 100px;
  height: 100px;
  background-color: red;
  filter: blur(5px);
  z-index: -1;
  animation: move 15s linear infinite;
}
.box2 {
  position: relative;
  width: 100vw;
  height: 100vh;
}
.box2::before {
  content: " ";
  position: absolute;
  top: -0px;
  left: -0px;
  bottom: -0px;
  right: -0px;
  background-image: conic-gradient(
    from 36deg at 20% 80%,
    #a100ffff 0% 25%,
    #000000 25% 30%,
    #119cfdff 30% 50%
  );

  filter: blur(500px);
  z-index: -1;
  animation: move 15s linear infinite;
}
@keyframes move {
  from {
    transform: rotate(180deg);
  }

  to {
    transform: rotate(540deg);
  }
}
<!DOCTYPE html>
<html>
  <head>
    <title>Parcel Sandbox</title>
    <meta charset="UTF-8" />
  </head>

  <body>
    <div id="app"></div>
    <script src="src/index.js"></script>
    <link rel="stylesheet" type="text/css" href="src/styles.css" />
    <div>
      <div class="box">1<br />12</div>
      <div class="box2">1<br />12</div>
    </div>
  </body>
</html>

它应该看起来像最左边的Firefox,但最近,它显示了奇怪的线框图。是的,不久前情况并非如此.

我把代码codesandbox来复制效果

https://codesandbox.io/

它应该看起来像最左边的 Firefox

CSS 谷歌浏览器

评论

0赞 Brett Donald 11/13/2023
您上传了正确的图片吗?图像和代码沙盒看起来完全不同。
0赞 Zhiqiang Du 11/13/2023
image 是项目的屏幕截图。该问题在 codesandbox 中重复出现
0赞 CBroe 11/13/2023
您的问题的适当最小可重现示例直接属于您的问题;请不要只是将我们发送到外部平台。

答:

2赞 Hao Wu 11/13/2023 #1

您可以通过使用 3D 变换来强制激活硬件加速,以消除视觉伪影:

transform: rotate3D(0, 0, 1, 180deg);

不知道为什么它会发生在 Chrome 上,一定是最近引入的错误。

body {
  font-family: sans-serif;
}
p {
  column-fill: balance;
  column-count: 2;
}

.box {
  width: 100px;
  height: 100px;
  background-color: red;
  filter: blur(5px);
  z-index: -1;
  animation: move 15s linear infinite;
}
.box2 {
  position: relative;
  width: 100vw;
  height: 100vh;
}
.box2::before {
  content: " ";
  position: absolute;
  top: -0px;
  left: -0px;
  bottom: -0px;
  right: -0px;
  background-image: conic-gradient(
    from 36deg at 20% 80%,
    #a100ffff 0% 25%,
    #000000 25.5% 30%,
    #119cfdff 30.5% 50%
  );

  filter: blur(500px);
  background-color: white;
  z-index: -1;
  animation: move 15s linear infinite;
}
@keyframes move {
  from {
    transform: rotate3D(0, 0, 1, 180deg);
  }

  to {
    transform: rotate3D(0, 0, 1, 540deg);
  }
}
<!DOCTYPE html>
<html>
  <head>
    <title>Parcel Sandbox</title>
    <meta charset="UTF-8" />
  </head>

  <body>
    <div id="app"></div>
    <script src="src/index.js"></script>
    <link rel="stylesheet" type="text/css" href="src/styles.css" />
    <div>
      <div class="box">1<br />12</div>
      <div class="box2">1<br />12</div>
    </div>
  </body>
</html>