当前位置:网站首页>Special effects - click the mouse, and a random color of love will appear
Special effects - click the mouse, and a random color of love will appear
2022-07-24 06:39:00 【Jie_ one thousand nine hundred and ninety-seven】
Mouse click , Love with random colors
One . design sketch

Two . Implementation code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Click the mouse to show random colors of love </title>
<style> * {
margin: 0; padding: 0; } html {
background-color: #c3ecff; } </style>
</head>
<body>
<script type="text/javascript"> ! function (e, t, a) {
function r() {
for (var e = 0; e < s.length; e++) 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"); requestAnimationFrame(r) } function n() {
var t = "function" == typeof e.onclick && e.onclick; e.onclick = function (e) {
t && t(), o(e) } } function o(e) {
var a = t.createElement("div"); a.className = "heart", s.push({
el: a, x: e.clientX - 5, y: e.clientY - 5, scale: 1, alpha: 1, color: c() }), t.body.appendChild(a) } function i(e) {
var a = t.createElement("style"); a.type = "text/css"; try {
a.appendChild(t.createTextNode(e)) } catch (t) {
a.styleSheet.cssText = e } t.getElementsByTagName("head")[0].appendChild(a) } function c() {
return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math .random()) + ")" } var s = []; e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e .mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
setTimeout(e, 1e3 / 60) }, 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;}" ), n(), r() }(window, document); </script>
</body>
</html>
边栏推荐
- 在IDEA里斗个地主不过分吧!
- [award issuance] the results of the first essay solicitation activity in oneos zone were announced
- CentOS operating system security reinforcement
- 这些坑你不掌握,你还真不敢用BigDecimal
- Quick start of go language
- 磁盘管理和文件系统
- Install Apache manually
- Sed command
- Maximum value of jz47 gifts (dynamic planning ideas)
- Leetcode sword finger offer JZ9 dual stack implementation queue
猜你喜欢
随机推荐
Browser local storage
Speed pointer in JS linked list
文件系统与日志分析
ESP32超详细学习记录:NTP同步时间
Custom MVC 1.0
Use of awk
[award issuance] the results of the first essay solicitation activity in oneos zone were announced
DHCP principle and configuration
Customize ZABBIX agent RPM package
Niuke net brush questions
Go environment construction and start
Remember 20 classic interview questions of performance test in three minutes
Luckyframeweb testing platform (a full latitude free open source testing platform that supports interface automation, Web UI automation, APP automation, and distributed testing)
United Nations agricultural products data analysis
Disk management and file system
go语言常用命令和包管理
NFS shared services and experiments
Leetcode sword finger offer jz25 merges two sorted linked lists
[219] what is the difference between app testing and web testing?
手动安装Apache









