广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    如何使用h5制作动态统计进度条

    来源:网络收集  点击:  时间:2024-07-29
    【导读】:
    现在h5小程序使用越来越多,随着h5的不断成熟,很多效果都可以使用h5来实现。本文简要介绍如何使用h5制作动态统计进度条。工具/原料morevs2015jquery方法/步骤1/6分步阅读

    需要下载jquery的js文件,并需要把文件添加到项目中,方便后面在页面引入使用。文件添加的位置,可以自己定义。这里我们使用的是jquery.min.3.4.1版本。

    2/6

    新建页面,并将jquery引入页面。

    script src=/bundles/jquery?201905280934/script

    3/6

    在新建的页面中,添加进度条生成的依赖容器。

    div class=statistic_wrap

    div class=statistic_content/div

    /div

    4/6

    编写进度条展示的模块及样式。模块可按照自己的具体展示来实现,样式如下:

    .statistic_wrap{padding: 0 0.2rem 1.07rem;}

    .statistic_content {width: 100%;}

    .widthBox {width:100%;background: rgba(255,255,255,0.7);margin-top: 0.4rem;border-radius: 4px;padding: 0.35rem;}

    .widthBox .title{color:#ffffff; text-align: left;font-size: 0.375rem; }

    .singleLine {border-bottom: 1px solid #f1f1f2;overflow: hidden;}

    .singleLine .sub-title{ text-align: left; color: #92b1d8;padding-bottom: 0;}

    .singleLine .lineData { margin-bottom: 0.37rem;position:relative; display:block; width:70%; background:#efefef; height:6px; border-radius:10px; -moz-border-radius:10px; -webkit-border-radius:10px; -webkit-transition:0.4s linear; -moz-transition:0.4s linear; -ms-transition:0.4s linear; -o-transition:0.4s linear; transition:0.4s linear; -webkit-transition-property:width, background-color; -moz-transition-property:width, background-color; -ms-transition-property:width, background-color; -o-transition-property:width, background-color; transition-property:width, background-color; float: left; }

    .singleLine .title { width:100%; font-size:0.4rem;padding: 0.32rem 0;padding: 0.37rem 0; line-height: 1;}

    .widthBox .singleLine:last-child{border: none;}

    5/6

    为了实现进度条的动态加载,我们需要使用jquery的animate方法来实现动态。

    $(.lineData).each(function ()

    {

    $(this).find(.bar).animate({

    width: $(this).attr(data)

    }, 1000);

    });

    6/6

    保存页面及样式,运行页面,即可得到如下效果,图1为初始加载的效果,图2为动态加载完成后的效果。

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_1031954.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-05 05:34:04  耗时:0.037
    0.0373s