Safari不会重绘由clip-path隐藏的元素

时间:2017-04-02 20:00:52

标签: css safari clip-path

我遇到了一个奇怪的狩猎虫,它使一些元素看不见,直到它们悬停在上面。

这是由先前使用clip(clip-path)隐藏的元素引起的。 Safari仅在悬停效果改变了设计后重新绘制它们,从而迫使safari重绘对象。

.logo-container {
  position: absolute;
  top: 0px;
  clip: rect(0, auto, auto, 0);
  clip-path: inset(0, auto, auto, 0);
}

1 个答案:

答案 0 :(得分:2)

为了解决这个问题,我使用重复的css动画来强制safari每秒重绘一次元素。

@-webkit-keyframes mymove {
from {top: 0px;}
to {top: 0.01px;}
}

.logo-container {
  position: absolute;
  top: 0px;
  clip: rect(0, auto, auto, 0);
  clip-path: inset(0, auto, auto, 0);
  -webkit-animation: mymove 0.1s infinite; /* Safari 4.0 - 8.0 */
}

现在重新绘制元素,可见性按预期工作。

如果有更好的解决方案可以回答这个问题:)