少し「大きな」問題があり、解決方法がわかりません。
margin-top を持つ要素にジャンプするアンカーを含むリンクがある場合、次の例のようにマージンは「無視」されます。
margin-top="0" の div があり、いくつかの margin-top が動的に追加される場合、アンカーは次の例のように「古い」位置にジャンプします。
ターゲット要素に動的に変更されたマージンがあることをアンカーに伝えることは可能ですか?
単一のコード スニペットを次に示します。
HTML
<a href="#testanchor" class="link">Testanchor</a>
<div id="zwischenelement"></div>
<div id="testanchor">Hier muss der Anker hinspringen</div>
CSS
body {
height: 8000px;
}
.link {
display: block;
}
#zwischenelement {
height: 200px;
background-color: grey;
}
#testanchor {
margin-top: 40px;
background-color: red;
padding:15px;
}
JS (「scrollAnimate」jQuery プラグインが含まれています)
$(document).ready(function() {
$('#testanchor').scrollAnimate({
startScroll: 0,
endScroll: 100,
cssProperty: 'margin-top',
before: 0,
after: 40
});
});
ご協力ありがとうございました。