登录  | 立即注册

游客您好!登录后享受更多精彩

查看: 1457|回复: 0

[js,sql,html教程] 【JS源码】点击心形

[复制链接]

444

主题

509

帖子

2051

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2051

荣誉管理论坛元老

发表于 2021-6-30 23:29:35 来自手机 | 显示全部楼层 |阅读模式 来自:
  1. <body>
    ' ^3 ]  Z+ o# Q* g+ K9 X9 B
  2. <script>
    4 @$ u4 ]3 \9 L
  3.         !function(e, t, a) {                 9 {# Z* a( h- G2 f- l  O" }* p- s
  4.                 function r() {                         1 M! u: i' y- T1 k  b7 K! V
  5.                         for (var e = 0; e < s.length; e++)! E* v0 k. W& R# H/ B
  6.                          s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");                        
    0 M  ~9 S! t0 ]& q( ?
  7.                          requestAnimationFrame(r)                
    1 L$ Q& w/ J* T
  8.                          }                 . n/ i7 I5 k/ e
  9.                          function n() {                         - o3 T+ J" U+ k' o, r& P( p; _' S
  10.                                  var t = "function" == typeof e.onclick && e.onclick;                        
    " f. E1 {0 l# X- V& G0 A
  11.                                  e.onclick = function(e) {                                 , m  a6 Z8 A; R/ v3 R7 \4 u
  12.                                          t && t(),                                        
    ( l  y+ e3 @& E9 J: V9 R+ U& y- v
  13.                                          o(e)                         # ^2 S9 v1 t* B) O+ U" H
  14.                                          }                
      N+ P" q4 U$ o( [+ L
  15.                                          }                
    1 O$ w# x1 B& p9 a3 m- S1 u
  16.                                          function o(e) {                         ! N; d( y' Z: Q3 W0 W
  17.                                                  var a = t.createElement("div");                         7 X* f  T% y- c2 v& C! U  U. @
  18.                                                  a.className = "heart",                                 4 N7 K! e8 s$ C5 w9 L! g+ q
  19.                                                  s.push({                                         6 f. [; r2 h  k+ l" V4 G
  20.                                                          el: a,                                        
    ( R8 [  n7 @- m6 Y* Z  O) e
  21.                                                          x: e.clientX - 5,                                        
      t& }: M0 _6 B4 o2 K
  22.                                                          y: e.clientY - 5,                                           t* ]! {2 Z9 b% _1 W0 N) [* P' s- `
  23.                                                          scale: 1,                                        
    $ ~# L9 t: ~! m  r8 r
  24.                                                          alpha: 1,                                        
    ' I0 y  ?5 J* j" w
  25.                                                          color: c()                                 & U/ t1 e* B! T" K9 T
  26.                                                          }),                                 ( e5 y2 Z1 M; }( G  E
  27.                                                          t.body.appendChild(a)                 $ {6 l  o  S& i' L% B5 n
  28.                                                          }                 ! |# G0 m+ B* k2 m# g5 n6 `% n1 ]
  29.                                                          function i(e) {                        
    9 t# a7 ~1 j5 Q& n$ k2 c9 p& `8 H$ C
  30.                                                                  var a = t.createElement("style");                        
    ( G, M: l2 E' u  @( v
  31.                                                                  a.type = "text/css";                         $ B  `  F" _. s8 {1 \6 U& D/ U
  32.                                                                  try {                                 8 @8 |; D' n0 [7 {- m
  33.                                                                          a.appendChild(t.createTextNode(e))                         ) n. Z: X! T$ W  ~" ?" z8 y+ |
  34.                                                                          } catch(t) {                                
    ( H6 C0 Q- O. U' j, L
  35.                                                                                  a.styleSheet.cssText = e                         + j1 U/ v) R( ^. n: N: k
  36.                                                                                  }                         ) D. ]+ ~# p/ Z
  37.                                                                                  t.getElementsByTagName("head")[0].appendChild(a)                
    8 P- X. {0 v$ x8 W0 o4 y
  38.                                                                                  }                
    3 v$ n: _8 P) N& i
  39.                                                                                  function c() {                        
      `5 `* ~0 n) ~) N9 Y6 b. q
  40.                                                                                          return "rgb(" + ~~ (255 * Math.random()) + "," + ~~ (255 * Math.random()) + "," + ~~ (255 * Math.random()) + ")"                 ! q* B/ g. b* d) ], j
  41.                                                                                          }                 ( Q* m" A6 ^7 n, i/ N5 g
  42.                                                                                          var s = [];                 ' i! W4 F1 E. M" P$ v# @
  43.                                                                                          e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame ||                         function(e) {                         setTimeout(e, 1e3 / 60)                         },                         1 G2 l" j" {7 x3 b/ l
  44.                                                                                                  i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),                         2 p" B- E' o9 q
  45.                                                                                                  n(),                        
    ) Z# q6 E1 w0 f
  46.                                                                                                  r()        
    , f- \" w, O6 F+ Z2 y
  47.                                                                                                  } (window, document); , G& k  y2 Z! P3 |- J3 F( @
  48.                                                                                                  </script>
    ( g% P9 M- q, [! _- O5 o
  49.                                                                                                  </body>
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|星空社区 |网站地图

GMT+8, 2024-4-19 14:21 , Processed in 0.055443 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表