javascript - 添加 will-change: transform 到 css 会导致图片消失
问题描述
我在将这个属性添加到 img 和 div 标签时遇到了一些关于 will-change: transform 的奇怪问题。基本上,我有一个 div 作为容器,其中包含一个 img 元素作为其子元素,并且我在 webkit 中滚动浏览这些图像。添加 will-change-transform 极大地提高了滚动性能,但是当您滚动时,您会间歇性地看到图像消失(或隐藏)。解决这个问题的任何答案都会很棒,因为我已经用尽了我从在线资源中尝试过的大部分解决方案。
我附上了 CSS 的代码片段:
“.cell”和“.pagNum”是 div 的类名属性。".pageNum" 是 img div(.cell) 顶部的页码 div。“.cell” div 包含 img 元素。
img {
position: relative;
-webkit-user-drag: none;
will-change: transform;
}
.cell {
position: absolute;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
will-change: transform;
}
.pageNum {
display: inline-block;
position: absolute;
top: 273px;
background-position: center;
text-align: center;
line-height: 36px;
min-width: 36px;
padding-left: 6px;
padding-right: 6px;
-webkit-border-radius: 3px;
background-color: rgba(0, 0, 0, .50);
color: white;
font-size: medium;
font-weight: bold;
text-shadow: 0px 1px 0px #000000;
left: 50%;
margin: 0px 0 0 -32px;
will-change: transform;
}
解决方案
推荐阅读
- python - 如何找到多条线与曲线的交点?
- python - Airflow 操作员是否需要返回任何内容才能正常运行?
- python - 计算子串计数
- java - Spring Cache 未创建代理类
- android - Capacitor 应用程序上的 Espresso 测试显示“无法在 45 秒内启动 Intent Intent”
- domain-driven-design - 如何在处理不同地区的领域专家语言时保持 UL 一致
- count - Halcon - 计算孔数
- fastapi - FastAPI @repeat_every 如何防止并行 defcheduled_task() 实例
- javascript - 日期过去时删除元素
- javascript - 如何使列表显示在 React 中的正确列和行中