sticky-kit
v1.1.2。
我读过这个
trouble shooting guide
我的代码显示在下面。我故意省略了以下两个div,因为我不确定它们应该插入哪里(我尝试了许多场景,但没有一个适合我):
<div class="sticky-parent">
<div class="sticky-spacer">
</div>
</div>
这是我的HTML代码:
<div id="id_side_advert_container" class="side_advert col-md-2">
<div class="margin-bottom-20">
<div id="id_side_advert_wrapper">
{# google adsense code to display side advertiements #}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- zoodal-side-advertisement-responsive -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1234567890112987"
data-ad-slot="1234567890"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</div>
// sticky-kit code for the side advertising sticky - with an offset of 15px when sticky.
$("#id_side_advert_container").stick_in_parent({
offset_top: 15,
parent: ".sticky-parent", // note: we must now manually provide the parent
spacer: ".sticky-spacer",
});
// the following code is the workaround so that the sticky element does not disappear when bottom -
// taken from: https://github.com/leafo/sticky-kit/issues/31 danxshap
$('#id_side_advert_container')
.on('sticky_kit:bottom', function(e) {
$(this).parent().css('position', 'static');
})
.on('sticky_kit:unbottom', function(e) {
$(this).parent().css('position', 'relative');
})