国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

H5實現中獎記錄逐行滾動切換效果

2019-11-19 17:10:58
字體:
來源:轉載
供稿:網友

本文實例為大家分享了H5逐行滾動切換效果的具體代碼,供大家參考,具體內容如下

前端頁面需先引入jquery

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>中獎記錄跑馬燈特效</title>  <script src="../js/jquery-2.2.0.min.js"></script>  <script src="../js/recordRoll.js"></script>  <style>    .box{      width: 18rem;      height: 15rem;      margin: auto;      background-color: cadetblue;    }    .record_title{      text-align: center;      width: 100%;      height: 2rem;      margin-top: 0.2rem;      z-index: 2;      background-color: cadetblue;      vertical-align: middle;    }    .record_list{      height: 11rem;      overflow: hidden;      background-color: cadetblue;      text-align: left;      margin-left: 1rem;    }  </style></head><body>  <div class="box">    <div class="record_title">    <h1>中獎記錄</h1>    </div>    <div class="record_list">      <p>恭喜Ivy抽中10元話費</p>      <p>恭喜LinDL抽中100元京東E卡</p>      <p>恭喜Mary抽中40元電影票優惠券</p>      <p>恭喜Ivy抽中30元話費</p>      <p>恭喜金坎抽中50元話費</p>      <p>恭喜Ivy抽中80元話費</p>      <p>恭喜Ivy抽中200元話費</p>      <p>恭喜慧林抽中5000元話費</p>      <p>恭喜張敏抽中iPhone7</p>      <p>恭喜Ivy抽中10元話費</p>    </div>  </div></body><script>  $(document.body).ready(function(){    $(".record_list").RollTitle({line:1,speed:800,timespan:1});  });</script></html>

利用定時器實現中獎記錄逐行展示
recordRoll.js

/** * Created by lin on 2017/3/12. */(function($){  $.fn.extend({    RollTitle: function(opt){      if(!opt) var opt={};      var _this = this;      _this.timer = null;      _this.lineH = _this.find("p:first").height();      _this.line=opt.line?parseInt(opt.line,15):parseInt(_this.height()/_this.lineH,10);      _this.speed=opt.speed,      _this.timespan=opt.timespan;      if(_this.line==0) this.line=1;      _this.scrollUp=function(){        _this.animate({          marginTop:0        },_this.speed,function(){          for(i=1;i<=_this.line;i++){            _this.find("p:first").appendTo(_this);          }          _this.css({marginTop:0});        });      }      _this.hover(function(){        clearInterval(_this.timer);      },function(){        _this.timer=setInterval(function(){_this.scrollUp();},_this.timespan);      }).mouseout();    }  })})(jQuery);

效果圖:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 徐汇区| 桂东县| 高陵县| 洛阳市| 太和县| 海丰县| 浦东新区| 晴隆县| 东乡族自治县| 香格里拉县| 乌兰察布市| 平江县| 荔浦县| 霍邱县| 威宁| 雷山县| 洛阳市| 宁夏| 凤翔县| 青海省| 呼玛县| 阆中市| 肇州县| 陇川县| 五大连池市| 那曲县| 威信县| 闸北区| 将乐县| 柯坪县| 镇安县| 湾仔区| 任丘市| 浙江省| 尤溪县| 台东市| 巫溪县| 东阿县| 西藏| 和龙市| 通辽市|