• 页面横向滚动 联动 进度条


    //效果图

    *{margin: 0;padding: 0;}
    .wrap{
    100%;height: 100%;display: flex;
    flex: 1;flex-direction: column;
    }
    .boy1{
    100%;overflow: auto;
    }
    .myFan{
    400%;height: 150px;display: flex;
    }
    .myFan>div{
    25%;height: 150px;border-right: 1px solid blueviolet;
    text-align: center;line-height: 150px;
    }
    .boy2{
    100%;display: flex;
    justify-content: center;
    }
    .boy2>div{
    100px;background: grey;
    border-radius: 5px;
    }
    .myScrollBar{
    padding: 0.3rem 0;background: red;
    border-radius: 5px;
    }



    <div class="wrap"> <div class="boy1"> <div class="myFan"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> </div> </div> <div class="boy2"> <div> <p class="myScrollBar"></p> </div> </div> </div>

    js

    var boy1 = document.getElementsByClassName("boy1")[0],  //获取元素
    myScrollBar = document.getElementsByClassName("myScrollBar")[0],
    myFan = document.getElementsByClassName("myFan")[0];

    myScrollBar.style.width = "25px";


    boy1.onscroll= function(){
      let nu = boy1.scrollLeft/boy1.offsetWidth/4; //移动的距离 / 获取显示的盒子宽  获取到一个百分比
      myScrollBar.style.marginLeft = 100*nu+"px";  //获取到的百分比处理下直接赋值回去
    }

  • 相关阅读:
    文件的操作
    encode,decode,str,bytes
    字符串操作
    suse12安装mysql8.16
    VMware配置共享磁盘安装RAC
    Linux过滤文本并显示过滤文字的上下文
    Linux服务器卸载mysql指南
    oracle 各版本各日志存放位置
    impdp按用户导入
    数据泵expdp定时备份
  • 原文地址:https://www.cnblogs.com/zqxi/p/12104392.html
Copyright © 2020-2023  润新知