免責事項:
私はこれがthis reported bugに関連し、そしてthis other questionと非常によく似ているが、修正がそこは適用されません示唆されたと仮定します。CSSハック
私はそれがposition: fixed; top: 0px;
を持っている。すなわち、スティッキーあるdiv
持っている場合。
ボディ/スクリーンの上部に付いている/付箋が付いていると思います。
親にフィルタを適用すると、本文にはposition: fixed;
という参照として親要素(フィルタを追加したもの)を採用することになります(Firefoxのみ)。
例(https://jsfiddle.net/sz6xtfno/):
(それはFirefoxでfixed
あるべきとき、div.sticky
変更位置に注意してください)
// just for demo purpose:
const sticky = document.querySelector('.sticky');
const container = sticky.parentElement;
setTimeout(() => container.classList.add('add-filter'), 1000);
html,
body {
margin: 0px;
padding: 0px;
height: 100%;
}
.sticky {
display: block;
position: fixed;
top: 0px;
}
.add-filter {
-webkit-filter: sepia(10%) grayscale(60%);
-moz-filter: sepia(10%) grayscale(60%);
filter: sepia(10%) grayscale(60%);
}
div {
background-color: #ddf;
padding: 10px;
margin: 0px;
position: relative;
}
<div>
<p>Previous element</p>
</div>
<div class="container">
<p>This is the container</p>
<div class="sticky">
<p>This is a sticky element</p>
</div>
</div>
質問:
修正する方法この?私はこの問題が測位計算を混乱させるようであるため、JavaScriptなしのソリューションを探しています。
を囲む親要素の座標系を持っていますか?私。 "ポジション=相対"なのか?私はFFが(少なくとも過去に)親が明示的に座標を述べることを望んでいることを発見しました。これは 'body'要素または囲む' div'要素で行うことができます。ちょっとした考え。 –
@PeterRowell私の例では、すべてのdivに 'position:relative;'を付けます。 – Sergio
申し訳ありません。遅れていて、私はあまりにも早くその例を取り上げました。 'body'に' position = relative'を追加すると助けになりますか? –