Javascript 滚动以使div可见
我试图使fullcalendar调度程序滚动到用户单击的区域,这段代码在某种程度上起作用,但根据屏幕大小,它应该缩放到的实际区域通常会滚动过去,并且在窗口中不可见 有没有办法确保表头单元格的左边框与窗口的左边框对齐 在视图中,在divJavascript 滚动以使div可见,javascript,jquery,fullcalendar,fullcalendar-scheduler,Javascript,Jquery,Fullcalendar,Fullcalendar Scheduler,我试图使fullcalendar调度程序滚动到用户单击的区域,这段代码在某种程度上起作用,但根据屏幕大小,它应该缩放到的实际区域通常会滚动过去,并且在窗口中不可见 有没有办法确保表头单元格的左边框与窗口的左边框对齐 在视图中,在div$('.fc-time-area.fc-widget-header.fc scroller')中有一个水平滚动表,可以找到我想要可见的单元格,如下所示:$(“.fc-time-area.fc-widget-header.fc content th[data date
$('.fc-time-area.fc-widget-header.fc scroller')
中有一个水平滚动表,可以找到我想要可见的单元格,如下所示:$(“.fc-time-area.fc-widget-header.fc content th[data date='2017-2-11T10:00'])
我想出来了。显然,使用
offset()
和position()
是有区别的。通过改变这个简单的东西,它现在工作得很好
var centerTime = function (day) {
$('.fc-time-area.fc-widget-header .fc-scroller').animate({
scrollLeft: $(".fc-time-area.fc-widget-header .fc-content").find("th[data-date='" + day + "']").offset().left
}, 750);
};
var centerTime = function (day) {
$('.fc-time-area.fc-widget-header .fc-scroller').animate({
scrollLeft: $(".fc-time-area.fc-widget-header .fc-content").find("th[data-date='" + day + "']").offset().left
}, 750);
};