jQuery好玩的插件



樱花下落特效

  1. 引入js

    1
    2
    <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/JQuery-Snowfall/1.7.4/snowfall.jquery.min.js"></script>
  2. Demo

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    <!DOCTYPE html <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>樱花下落特效</title>
    <link rel="stylesheet" href="css/liMarquee.css">
    <!-- <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> -->
    <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/JQuery-Snowfall/1.7.4/snowfall.jquery.min.js"></script>
    <!-- 文字走马灯特效 -->
    <script src="js/jquery.liMarquee.js"></script>
    </head>

    <body>
    <div style="height:900px; width:100%">
    <div class="str1 str_wrap">
    <p>我见过的最美的春天,是你穿过人群找到我的那个四月。🌹</p>
    </div>
    </div>
    <script>

    $(document).click(function () {
    $(document).snowfall('clear');
    })
    $(document).dblclick(function () {
    sakura()
    })

    function sakura() {
    $(document).snowfall({
    // 这里可以通过自定义下落的的图片
    image: "sakura.png",
    flakeCount: 50,
    minSize: 20,
    maxSize: 35,
    minSpeed: 1,
    maxSpeed: 2
    })
    }
    setTimeout(() => {
    sakura()
    }, 1000);
    </script>
    </body>

    </html>

bxslider滚动插件使用

  1. 引入js文件

    1
    2
    <script src="https://cdn.bootcss.com/jquery/2.2.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bxslider/4.2.10/jquery.bxslider.js"></script>
  2. Demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<html>
<head>
<title>bxSlider使用</title>
<link rel="stylesheet" type="text/css" href="jquery.bxslider.css" />
<script src="https://cdn.bootcss.com/jquery/2.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bxslider/4.2.10/jquery.bxslider.js"></script>

<!--轮播-->
<div>
<div class="list_base" style="height:200px;overflow: hidden;">
<div class="t4_list_tit">
<span class="ssmc" style="width:38%;">企业名称 </span>
<span class="ssmc" style="width:18%;">行业类别</span>
<span class="xyd" style="width:15%;">申请人</span>
<span class="xyd" style="width:18%;">注册时间</span>
</div>
<ul id="t4_leftTabSlider">
</ul>
</div>
</div>

<script type="text/javascript">
const data = [{
NAME: '深圳通讯',
CATEGORIES: '软件',
PROPOSER: '小明',
CREATE_TIME: '2020-02-12',
},
{
NAME: '中讯科技',
CATEGORIES: '软件',
PROPOSER: '小红',
CREATE_TIME: '2021-02-12',
}
]
if (data && data.length > 0) {
console.log(data)
data.forEach(item => {
// const itemLi = '<li>' +
// '<span class="ssmc nameItem" style="width:38%;">' + item.NAME +'</span>' +
// '<span class="xyd categories" style="width:18%;">' + item.CATEGORIES +'</span>' +
// '<span class="xyd proposer" style="width:15%;position: relative;left: 2%;">' + item.PROPOSER +' </span>' +
// '<span class="xyd create_time" style="width:18%;position: relative;left: 3%;">' + item.CREATE_TIME +'</span>' +
// '</li>';

let itemLi = '<li>'
itemLi += '<span class="ssmc nameItem" style="width:38%;">' + item.NAME +'</span>'
itemLi += '<span class="xyd categories" style="width:18%;">' + item.CATEGORIES +'</span>'
itemLi += '<span class="xyd proposer" style="width:15%;position: relative;left: 2%;">' + item.PROPOSER +' </span>'
itemLi += '<span class="xyd create_time" style="width:18%;position: relative;left: 3%;">' + item.CREATE_TIME +'</span>'
itemLi += '</li>';

$('#t4_leftTabSlider').append(itemLi)
})

$(document).ready(function () {
$('#t4_leftTabSlider').bxSlider({
autoHover: false,
tickerHover: true,
mode: 'vertical',
slideMargin: 0,
minSlides: 8,
maxSlides: 8,
ticker: true,
// (数据总数/10)*12000
speed: 5000,
useCSS: false
});
});
}
</script>
</html>

注意:

要是需要使用jQ的append()拼接,那么我们需要先拼接好,再调用方法,不然容易数据正常,但是没有渲染进去。
而且bxslider的滚动机制是会复制一份需要被滚动的数据的标签和值。

  1. 需要查询后重置数据再滚动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<table>
<col style="width:65px">
<col style="width:420px">
<col style="width:150px">
<thead>
<tr>
<th>选择</th>
<th>名称</th>
<th>编码</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3" id="sa">

</td>
</tr>
</tbody>
</table>

①:先判断有不有被拼接的appendTable id,有的话必须清空了,不然append会在现有数据后拼接,而不是重置

1
2
3
4
5
6
7
if($('#appendTable')){
// 将表格去除
// $('#appendTable').remove();
// 将重新bxSlider自动生成在table上的div也重置清空,即sa下的都重置,目的让table再重新生成,不然数据查出来没有滚动。
// html() 方法返回或设置被选元素的内容 (inner HTML)。
$("#sa").html('');
}

②:创建appendTable的节点,并赋予id、class属性

1
2
3
4
const _winTable = document.createElement('table');
_winTable.id='appendTable';
_winTable.className = 'bxslider';
$("#sa").append(_winTable);

③:拼接整体内容数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
let itemLi='<tbody>';
// 查询出来的数据集合
data.forEach(item => {
itemLi += '<tr>'
itemLi += '<td style="width:65px">'
itemLi += '<div class="check_box_div">'
itemLi += '<span class="remember"><i class="ncheck1"></i></span>'
itemLi += '</div>'
itemLi += '</td>'
itemLi += '<td style="width:420px">' + item.NAME + '</td>'
itemLi += '<td style="width:150px">' + item.INDEX + '</td>'
itemLi += '</tr>'
})
itemLi += '</tbody>'

④:重新渲染表格数据

1
$('#appendTable').html(itemLi)

⑤:调用滚动函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function roll() {
const set = {
autoHover:false,
tickerHover:true,
mode:'vertical',
slideMargin: 1,
minSlides: 3,
maxSlides: 5,
ticker: true,
speed:13000,
useCSS:false
};
$('.bxslider').bxSlider(set);
}

3d立体魔方(原生实现)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<html>
<style>
/*最外层容器样式*/
.wrap {
width: 0px;
height: 0px;
/*margin: 80px;*/
/*position: relative;*/
position: fixed;
bottom: 120px;
right: 80px;
z-index: 999;
}

/*包裹所有容器样式*/
.cube {
width: 0px;
height: 0px;
margin: 0 auto;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
transform: rotateX(-30deg) rotateY(-80deg);
animation: rotate linear 10s infinite;
}

@-webkit-keyframes rotate {
from {
transform: rotateX(0deg) rotateY(0deg);
}
to {
transform: rotateX(360deg) rotateY(360deg);
}
}

.cube div {
position: absolute;
width: 50px;
height: 50px;
opacity: 0.8;
transition: all .4s;
}

/*定义所有图片样式*/
.pic {
width: 50px;
height: 50px;
}

.cube .out_front {
transform: rotateY(0deg) translateZ(25px);
}

.cube .out_back {
transform: translateZ(-25px) rotateY(180deg);
}

.cube .out_left {
transform: rotateY(-90deg) translateZ(25px);
}

.cube .out_right {
transform: rotateY(90deg) translateZ(25px);
}

.cube .out_top {
transform: rotateX(90deg) translateZ(25px);
}

.cube .out_bottom {
transform: rotateX(-90deg) translateZ(25px);
}

/*定义小正方体样式*/
.cube span {
display: block;
width: 25px;
height: 25px;
position: absolute;
top: 12px;
left: 12px;
}

.cube .in_pic {
width: 25px;
height:25px;
}

.cube .in_front {
transform: rotateY(0deg) translateZ(12px);
}

.cube .in_back {
transform: translateZ(-12px) rotateY(180deg);
}

.cube .in_left {
transform: rotateY(-90deg) translateZ(12px);
}

.cube .in_right {
transform: rotateY(90deg) translateZ(12px);
}

.cube .in_top {
transform: rotateX(90deg) translateZ(12px);
}

.cube .in_bottom {
transform: rotateX(-90deg) translateZ(12px);
}

/*鼠标移入后样式*/
.cube:hover .out_front {
transform: rotateY(0deg) translateZ(50px);
}

.cube:hover .out_back {
transform: translateZ(-50px) rotateY(180deg);
}

.cube:hover .out_left {
transform: rotateY(-90deg) translateZ(50px);
}

.cube:hover .out_right {
transform: rotateY(90deg) translateZ(50px);
}

.cube:hover .out_top {
transform: rotateX(90deg) translateZ(50px);
}

.cube:hover .out_bottom {
transform: rotateX(-90deg) translateZ(50px);
}
</style>

<div class="wrap">
<!--包裹所有元素的容器-->
<div class="cube">
<!--前面图片 -->
<div class="out_front">
<a onclick="back2top()">
<img src="https://img-blog.csdnimg.cn/20200420091226879.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNDc2NDY1,size_16,color_FFFFFF,t_70" class="pic" />
</a>
</div>
<!--后面图片 -->
<div class="out_back">
<a onclick="back2top()">
<img src="https://f12.baidu.com/it/u=2307169604,3228973864&fm=72" class="pic" />
</a>
</div>
<!--左面图片 -->
<div class="out_left">
<a onclick="back2top()">
<img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=977470203,949183840&fm=26&gp=0.jpg" class="pic" />
</a>
</div>
<!--右面图片 -->
<div class="out_right">
<a onclick="back2top()">
<img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3353784624,2171023218&fm=26&gp=0.jpg" class="pic" />
</a>
</div>
<!--上面图片 -->
<div class="out_top">
<a onclick="back2top()">
<img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=665381227,1787391012&fm=26&gp=0.jpg" class="pic" />
</a>
</div>
<!--下面图片 -->
<div class="out_bottom">
<a onclick="back2top()">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2528328792,546048564&fm=26&gp=0.jpg" class="pic" />
</a>
</div>

<!--小正方体 -->
<span class="in_front">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4041453540,598406734&fm=11&gp=0.jpg" class="in_pic" />
</span>
<span class="in_back">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4041453540,598406734&fm=11&gp=0.jpg" class="in_pic" />
</span>
<span class="in_left">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4041453540,598406734&fm=11&gp=0.jpg" class="in_pic" />
</span>
<span class="in_right">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4041453540,598406734&fm=11&gp=0.jpg" class="in_pic" />
</span>
<span class="in_top">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4041453540,598406734&fm=11&gp=0.jpg" class="in_pic" />
</span>
<span class="in_bottom">
<img src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=4041453540,598406734&fm=11&gp=0.jpg" class="in_pic" />
</span>
</div>

</div>

<script>
function back2top(){
$('html, body').animate({scrollTop: 0}, 500);
}
</script>
</html>
  1. 效果图片
打赏
  • 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!
  1. © 2020 Liu Yang    湘ICP备20003709号

请我喝杯咖啡吧~

支付宝
微信