我想创建一个动态滚动内容。
首先,我检索数据并设置内容
$("#sub_menu li").on("click", function () {
$("#gallery").html(get_html($(this).attr("id")));
$("#gallery").css("overflow-y", "scroll");
});
问题是,在添加新内容之后,如果我没有具体说明溢出-y,它没有滚动条,内容只保持其高度。那么,问题是,在更新可滚动div中的内容之后如何更新滚动条?
由于我想使用自定义滚动条插件,但在内容更新后它无效
http://manos.malihu.gr/jquery-custom-content-scroller/
这是css
#gallery {
width: 530px;
float: right;
height: 660px;
}
这是演示网站,只需按下“2016年夏季”
即可kotechweb.com/new_focus/page/inspiration
答案 0 :(得分:1)
可能会有所帮助
$("#sub_menu li").on("click", function () {
$("#gallery").html(get_html($(this).attr("id"))).promise().done(function(){
$(this).css("overflow-y", "scroll");
});
});
但我想知道为什么你不只是使用overflow-y : auto;
并删除$("#gallery").css("overflow-y", "scroll");
#gallery {
width: 530px;
float: right;
height: 660px;
overflow-y : auto;
}
答案 1 :(得分:0)
尝试添加自定义滚动条插件advanced:{ updateOnSelectorChange: true }
的选项:
$("#gallery").mCustomScrollbar({
theme: "3d-thick",
advanced:{ updateOnSelectorChange: true }
});