jquery - 为stick_in_parent 设置新的offset_top
问题描述
我使用sticky-kit
Jquery 的框架来fix the sidebar
. 我成功地做到了,就像那样
这个网站已经把这段代码放在了它的js
部分。offset_top: 10
这个高度在向下滚动和向上滚动模式下都保持不变。它工作正常
如果您向上滚动,我想将其更改为 10 像素。如果向下滚动,距离为 0 像素
所以我写了下面的代码,但它不起作用:
if (scroll_to_top) {
$("#aside").stick_in_parent({
offset_top: 10
});
}
if (scroll_to_down) {
$("#aside").stick_in_parent({
offset_top: 0
});
}
我应该怎么办?
解决方案
尝试这个:
if (scroll_to_top) {
$("#aside").css({
"top": "10px"
});
}
if (scroll_to_down) {
$("#aside").css({
"top": "0px"
});
}
推荐阅读
- codenameone - 泛化代码以捕获和裁剪照片
- python - QUdpSocket 在 PyQt5 中没有 writeDatagram() 函数吗?
- d3.js - d3.js 中的时间格式 (%"Y")
- java - 有没有更好的方法来使用 Java 中的特定本地 IP 地址执行 ICMP Ping
- angular7 - 如何在 Angular 中动态显示 404
- godot - 如何将 queue_free() 与 Area2D 一起使用
- javascript - 如何通过对象数组中的键值合并或连接数据?
- javascript - 让 react-dropzone 接受 *all* 文件
- c# - 如何为所有控件、面板、文本块等设置背景属性?
- r - 在数据框中创建变量的正则表达式循环