手机版 | ------------全站资源有,统一解压码,解码平台,请点这里 ------------ 设首页 | 加收藏
当前位置: 网站首页 > jQuery库 > 文章 当前位置: jQ > 文章

jquery计数器动画特效

时间:2020-06-30    点击: 次    来源:网络    作者:佚名 - 小 + 大

jquery计数器动画特效
简要教程

这是一款jquery计数器动画特效。该jquery计数器动画特效使用bootstrap网格系统进行布局,然后通过jQuery animate方法来制作炫酷的计数器动画特效。

使用方法

在页面中引入jquery,bootstrap.min.css和font-awsome.min.css文件。

<link href="dist/bootstrap.min.css" rel="stylesheet"><link href="dist/font-awsome.min.css" rel="stylesheet"><script src="js/jquery.min.js"></script>                      
HTML结构

计数器的HTML结构如下:

<div class="container">    <div class="row">        <div class="col-md-3 col-sm-6">            <div class="counter">                <div class="counter-content">                    <i class="counter-icon fa fa-globe"></i>                    <span class="counter-value">75</span>                    <h3 class="title">Web Design</h3>                </div>            </div>        </div>        <div class="col-md-3 col-sm-6">            <div class="counter">                <div class="counter-content">                    <i class="counter-icon fa fa-rocket"></i>                    <span class="counter-value">100</span>                    <h3 class="title">Web Development</h3>                </div>            </div>        </div>    </div></div>                
CSS样式

为计数器添加下面的CSS样式:

.counter{    background: #7a7fb6;    text-align: center;    position: relative;}.counter .counter-content{    padding: 30px 20px 50px;    color: #fff;    position: relative;}.counter:before,.counter:after,.counter .counter-content:before,.counter .counter-content:after{    content: "";    width: 20px;    height: 20px;    border-radius: 50%;    background: #fff;    position: absolute;    box-shadow: inset 0 2px 2px #000;    top: 15px;    left: 15px;}.counter:after{    left: auto;    right: 15px;}.counter .counter-content:before,.counter .counter-content:after{    box-shadow: inset 0 -2px 2px #000;    top: auto;    bottom: 15px;}.counter .counter-content:after{    left: auto;    bottom: 15px;    right: 15px;}.counter .counter-icon{    display: inline-block;    font-size: 40px;    margin-bottom: 15px;}.counter .counter-value{    display: block;    font-size: 50px;    margin-bottom: 15px;}.counter .title{    font-size: 20px;    text-transform: uppercase;    text-shadow: 3px 3px 2px rgba(0, 0, 0, 0.71);}@media only screen and (max-width: 990px){    .counter{ margin-bottom: 20px; }}                                  
Javascript

在页面DOM元素加载完毕之后,通过下面的方法来初始化该jquery计数器。

$('.counter-value').each(function(){    $(this).prop('Counter',0).animate({        Counter: $(this).text()    },{        duration: 3500,        easing: 'swing',        step: function (now){            $(this).text(Math.ceil(now));        }    });});                           
 jquery计数器动画特效 本地下载

上一篇:jquery响应式lightbox插件Galpop

下一篇:jquery响应式模态窗口插件jquery.edbox

浙ICP备18035339号-15  |   QQ:79720816  |  地址:蚂蚁分享-一个只做有用的分享。  |  13388629007  |  
Copyright © 2023 蚂蚁分享网 版权所有,授权www.tanan.net使用 Powered by ANTQQ.COM