欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript Html實(shí)現(xiàn)移動(dòng)端紅包雨功能頁(yè)面

 更新時(shí)間:2021年01月10日 14:27:01   作者:Jeslie-He  
這篇文章主要為大家詳細(xì)介紹了JavaScript Html實(shí)現(xiàn)移動(dòng)端紅包雨功能頁(yè)面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Html實(shí)現(xiàn)移動(dòng)端紅包雨功能頁(yè)面的具體代碼,供大家參考,具體內(nèi)容如下

實(shí)現(xiàn)效果如下:

具體代碼如下

html部分:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title>紅包雨</title>
 <link rel="stylesheet" href="./css/demo.css" >
 <link rel="stylesheet" href="./css/index.css" >
</head>
<body>
 <!-- 紅包 -->
 <ul class="redPaper">
 <!-- <li>
 <a href="#" ><img src="./images/hb_1.png" alt=""></a>
 </li> -->
 </ul>
 <div class="backward">
 <span></span>
 </div>
 <script src="./js/jquery.min.js"></script>
 <script src="./js/index.js"></script>
 <script>
 
 </script>
</body>
</html>

demo.css為初始化css,可以不加

index.css部分

body{
 width: 100%;
 height: 100%;
 background-image: url(../images/bj.jpg);
 background-repeat: no-repeat;
 background-size: cover;
 position: relative;
}
.redPaper{
 width: 100%;
 height: 100%;
 /* border: 1px solid black; */
 overflow: hidden;
}
.redPaper li {
 position: absolute;
 animation: all 3s linear;
 top:-100px;
 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.redPaper li a{
 display: block;
}
.backward{
 width: 100%;
 background:#ccc;
 opacity: 0.5;
 position: absolute;
 top: 0;
 
}
.backward span{
 display: inline-block;
 width: 100px;
 height: 100px;
 color: #000;
 font-weight: bold;
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 bottom: 0;
 margin: auto;
 text-align: center;
 line-height: 100px;
 font-size: 1000%;
}

index.js部分:

$(document).ready(function () {
 var win = (parseInt($('.redPaper').css('width'))) - 60;
 console.log(win)
 $(".redPaper").css("height", $(document).height());
 $(".backward").css("height", $(document).height());
 $("li").css({});
 // 點(diǎn)擊確認(rèn)的時(shí)候關(guān)閉模態(tài)層
 // $(".sen a").click(function(){
 // $(".mo").css("display", "none")
 // });

 var del = function () {
 nums++;
 // console.info(nums);
 // console.log($(".li" + nums).css("left"));
 $(".li" + nums).remove();
 setTimeout(del, 200)
 }

 var addRedPaper = function () {
 var hb = parseInt(Math.random() * (3 - 1) + 1);
 var randomW = parseInt(Math.random() * (70 - 30) + 20);
 var randomLeft = parseInt(Math.random() * win);
 var randomRotate = (parseInt(Math.random() * 45)) + 'deg';
 // console.log(rot)
 num++;
 $(".redPaper").append("<li class='li" + num + "' ><a href='javascript:;'><img src='images/hb_" + hb + ".png' data-num ='" + num + "'></a></li>");
 $(".li" + num).css({
 "left": randomLeft,
 });
 $(".li" + num + " a img").css({
 "width": randomW,
 "transform": "rotate(" + randomRotate + ")",
 "-webkit-transform": "rotate(" + randomRotate + ")",
 "-ms-transform": "rotate(" + randomRotate + ")", /* Internet Explorer */
 "-moz-transform": "rotate(" + randomRotate + ")", /* Firefox */
 "-webkit-transform": "rotate(" + randomRotate + ")",/* Safari 和 Chrome */
 "-o-transform": "rotate(" + randomRotate + ")" /* Opera */
 });
 $(".li" + num).animate({ 'top': $(window).height() + 20 }, 5000, function () {
 //刪掉已經(jīng)顯示的紅包
 this.remove()
 });
 //點(diǎn)擊紅包的時(shí)候彈出模態(tài)層
 $(".li" + num).click(function (e) {
 if (e.target.tagName == 'IMG') {
 console.log(e.target.dataset.num)
 }

 });
 setTimeout(addRedPaper, 200)
 }

 //增加紅包
 var num = 0;
 setTimeout(addRedPaper, 3000);

 //倒數(shù)計(jì)時(shí)
 var backward = function () {
 numz--;
 if (numz > 0) {
 $(".backward span").html(numz);
 } else {
 $(".backward").remove();
 }
 setTimeout(backward, 1000)

 }

 var numz = 4;
 backward();

})

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 小程序?qū)崿F(xiàn)分頁(yè)查詢列表的模板

    小程序?qū)崿F(xiàn)分頁(yè)查詢列表的模板

    這篇文章主要為大家詳細(xì)介紹了小程序?qū)崿F(xiàn)分頁(yè)查詢列表的模板,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • js實(shí)現(xiàn)動(dòng)畫(huà)特效的文字鏈接鼠標(biāo)懸停提示的方法

    js實(shí)現(xiàn)動(dòng)畫(huà)特效的文字鏈接鼠標(biāo)懸停提示的方法

    這篇文章主要介紹了js實(shí)現(xiàn)動(dòng)畫(huà)特效的文字鏈接鼠標(biāo)懸停提示的方法,實(shí)例分析了javascript操作css的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-03-03
  • 基于微信小程序?qū)崿F(xiàn)透明背景人像分割功能

    基于微信小程序?qū)崿F(xiàn)透明背景人像分割功能

    這篇文章主要介紹了基于小程序?qū)崿F(xiàn)透明背景人像分割,此文主要實(shí)現(xiàn)識(shí)別人體的輪廓范圍,與背景進(jìn)行分離并保存效果圖,適用于拍照背景替換及透明背景的人像圖(png格式)轉(zhuǎn)換,需要的朋友可以參考下
    2022-10-10
  • JS Generator 函數(shù)的含義與用法實(shí)例總結(jié)

    JS Generator 函數(shù)的含義與用法實(shí)例總結(jié)

    這篇文章主要介紹了JS Generator 函數(shù)的含義與用法,結(jié)合實(shí)例形式總結(jié)分析了JS Generator 函數(shù)基本含義、用法及操作注意事項(xiàng),需要的朋友可以參考下
    2020-04-04
  • WEB前端實(shí)現(xiàn)裁剪上傳圖片功能

    WEB前端實(shí)現(xiàn)裁剪上傳圖片功能

    文件上傳功能在各大網(wǎng)站經(jīng)常會(huì)用到,今天小編通過(guò)本文給大家介紹了WEB前端實(shí)現(xiàn)裁剪上傳圖片功能的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • JS代碼優(yōu)化技巧之通俗版(減少js體積)

    JS代碼優(yōu)化技巧之通俗版(減少js體積)

    如果你問(wèn)我網(wǎng)站中最影響網(wǎng)站打開(kāi)速度的是什么?我會(huì)告訴是網(wǎng)站中的javascript,簡(jiǎn)稱JS。模板中引用的JS文件越多,打開(kāi)速度越慢,這點(diǎn)我深有體會(huì),不信你看看盧松松博客首頁(yè),使勁優(yōu)化后依然有100K的文件
    2011-12-12
  • JavaScript數(shù)組操作總結(jié)

    JavaScript數(shù)組操作總結(jié)

    JavaScript中的Array對(duì)象與其他編程語(yǔ)言中的數(shù)組一樣,是一組數(shù)據(jù)的集合。在JavaScript中,數(shù)組里面的數(shù)據(jù)可以是不同類型的,并具有用于執(zhí)行數(shù)組常見(jiàn)操作的方法,本文整理了一些常用的,需要的可以參考一下
    2022-10-10
  • Bootstrap模態(tài)對(duì)話框的簡(jiǎn)單使用

    Bootstrap模態(tài)對(duì)話框的簡(jiǎn)單使用

    這篇文章主要為大家詳細(xì)介紹了Bootstrap模態(tài)對(duì)話框的簡(jiǎn)單使用,感興趣的小伙伴們可以參考一下
    2016-04-04
  • js中的屏蔽的使用示例

    js中的屏蔽的使用示例

    本文為大家介紹下js中的屏蔽的應(yīng)用;屏蔽網(wǎng)頁(yè)內(nèi)容選中、剪切、復(fù)制及拷屏總之你能想象的應(yīng)該都有,感興趣的朋友可以參考下,希望對(duì)大家學(xué)習(xí)js有所幫助
    2013-07-07
  • 微信小程序模板之分頁(yè)滑動(dòng)欄

    微信小程序模板之分頁(yè)滑動(dòng)欄

    這篇文章主要為大家詳細(xì)介紹了微信小程序模板之分頁(yè)滑動(dòng)欄的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-02-02

最新評(píng)論