简单自动切换轮播图



window.onload = function() {
        setSliderWidth();
    }
function setSliderWidth() {
    const p = document.getElementsByClassName('slider')[0];
    const c = document.getElementsByClassName('slider-group')[0];
    const ifLoop = true;

    let children = c.children;
    let width = 0;
  //注意三个xxWidth值的区别,clientWidth包含了页面右侧滑轨的宽度
    // let sliderWidth = p.clientWidth;
    // let sliderWidth = p.offsetWidth;
    let sliderWidth = window.innerWidth;
    for(let i=0;i

你可能感兴趣的:(简单自动切换轮播图)