写在tab切换的方法里,其中tab标签绑定ID ‘pop-d-tab-’ + active_index
父标签绑定ID pop-d-tab
很简单的代码 记下来 随用随取。
const son_dom = document.getElementById('pop-d-tab-' + active_index);
const father_dom = document.getElementById('pop-d-tab');
if (son_dom) {
const clientWidth = father_dom.clientWidth;
// const scrollLeft = recommend_title_dom.scrollLeft;
const offsetLeft = son_dom.offsetLeft;
father_dom.scrollLeft = (offsetLeft - (clientWidth / 2) + son_dom.clientWidth / 2);
}
点击抑郁时候 tab发生切换动作 将它居中 后面的选项也漏出来了