水平滚动条复制
Horizontal Scrollbar replication
>我有一个带有一些隐藏td的表格,它有一个与表格宽度相对应的水平滚动条。加载时,表格的宽度没有滚动,因为我们单击展开按钮,隐藏的 td 被打开,表格的宽度大于查看空间,因此滚动条按预期填充。
现在,我有一个滚动条,相当于上面的表格;但是当点击展开按钮时,滚动条没有更新;它与加载时间相同。
我们有什么技术可以将表/div 元素滚动条的相同行为复制到虚拟滚动条中吗?
提前谢谢!!
这是我用来创建双滚动的内容 - 意思是将滚动附加到元素的顶部,因为默认情况下底部只有一个:
function appendFakeScroll(elementToAttachScrollTo) {
var newElementId = elementToAttachScrollTo[0].id + "Fake";
// Check if we already have a fake scroll
if (!$("#" + newElementId)[0]) {
// No fake scroll exist, let's create a container for the scroll. It has to be the same width as the element we just expanded.
var html = '<div style="overflow:auto;width:' + elementToAttachScrollTo.width() + 'px;height:17px;" id="' + newElementId + '">';
html += '<div style="width:' + elementToAttachScrollTo[0].scrollWidth + 'px; height: 17px;"></div>';
html += '</div>';
// Here we attach the created scrollbar to the top of the element with .before()
elementToAttachScrollTo.before(html);
}
// Create a jquery objekt of the now created fake scrollbar
var fakeScroll = $("#" + newElementId);
// Send the element we have the scrollbars in, as well as the fake scrollbar,
// to a function that links them together, so that scrolling the fake one
// also scroll the window and the real scrollbar, and wise versa
linkScrollWindows(elementToAttachScrollTo, fakeScroll);
}
function linkScrollWindows(elementToAttachScrollTo, fakeScroll) {
fakeScroll.scroll(function () {
elementToAttachScrollTo.scrollLeft(fakeScroll.scrollLeft());
});
elementToAttachScrollTo.scroll(function () {
fakeScroll.scrollLeft(elementToAttachScrollTo.scrollLeft());
});
}
相关文章:
- CSS-若窗口太小,滚动条会出现在“表格”单元格上
- 禁用(而不是隐藏)浏览器滚动条
- 在firefox和chrome中的左侧显示iframe滚动条
- jquery:将动画绑定到滚动条位置的更好方法
- 在窗口中添加滚动条
- 如何查明鼠标按下事件是否发生在滚动条上或元素中的其他任何位置
- 使用没有插件的javascript自定义滚动条
- CodeMirror.禁用垂直滚动条
- 在滚动时,在隐藏滚动条和隐藏溢出的同时触发事件
- 可以'无法使滚动条正常工作
- 强制滚动条覆盖页面内容
- 如何隐藏滚动条,但希望它继续工作
- 滚动所有嵌套的滚动条,使HTML元素进入视图
- 使用浏览器滚动条而不是iframe滚动条
- 滚动条在关闭引导对话框后消失
- javascript/获取滚动条位置的回调
- 可调整滚动条大小
- 去掉滚动条
- ext-js网格面板滚动条不适用于jquery
- 水平滚动条复制