我使用的是 Chrome 68。
每当我有filter: invert(xxx);
on the <body>
,任何定位为fixed
不会粘在屏幕上,它会随所有内容一起滚动。
演示与filter: invert(xxx);
body{
height: 8000px;
filter: invert(0.85);
}
div{
position: fixed;
top: 0;
left: 0;
height: 100px;
width: 100px;
border: 1px solid black;
}
<div></div>
演示不带filter: invert(xxx);
body{
height: 8000px;
}
div{
position: fixed;
top: 0;
left: 0;
height: 100px;
width: 100px;
border: 1px solid black;
}
<div></div>
编辑:在 Chrome 67 上工作正常,但在 Chrome 68 上不行。
它看起来像是 Google Chrome 68 上的错误,但您可以使用以下方法解决此问题<html>
元素而不是<body>
元素:
html {
height: 8000px;
filter: invert(0.85);
}
div {
position: fixed;
top: 0;
left: 0;
bottom: 0;
height: 100px;
width: 100px;
border: 1px solid black;
}
<div></div>
Note:仅以防万一top
and left
设置为 0 时元素不会保持固定在滚动状态。但如果你添加bottom: 0;
该元素再次保持固定。
我还比较了更新之前(Chrome 67)和之后(Chrome 68)的样式,并且在同一示例中更改了以下值(使用filter
):
+---------------+-----------------+
| Chrome 67 | Chrome 68 |
+---------------+-----------------+
| bottom: 97px; | bottom: 7898px; |
| right: 526px; | right: 510px; |
+---------------+-----------------+
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)