css+js实现鼠标锤子点击敲墙墙面文字破碎消散动画效果代码

代码语言:html

所属分类:动画

代码描述:css+js实现鼠标锤子点击敲墙墙面文字破碎消散动画效果代码

代码标签: css js 鼠标 锤子 点击 敲墙 墙面 文字 破碎 消散 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
<style>
@import url("https://fonts.googleapis.com/css2?family=Bangers&display=swap");

* {
	margin: 0;
	padding: 0;
}

body {
	overflow: hidden;
	font-family: "Bangers", system-ui;
	background-color: #f5f2fa;
	background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23f57f0a' fill-opacity='0.1'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.paragraph {
	font-size: 1.5rem;
	text-align: center;
	background-color: #f57f0a;
	-webkit-box-shadow: 9px 10px 0px -4px #000000;
	box-shadow: 9px 10px 0px -4px #000000;
	padding: 10px;
	width: 100%;
	max-width: 10rem;
	margin: 10px auto;
	color: black;
	border: 5px solid black;
}

#custom-cursor {
	position: absolute;
	width: 30px;
	height: 30px;
	font-size: 30px;
	pointer-events: none;
	transform: translate(-50%, -50%);
	z-index: 1000;
	transition: transform 0.1s ease;
}
</style>


</head>

<body>
  <div id="custom-cursor">🔨</div>
<div class="paragraph">We don’t need no education</div>
<div class="paragraph">We don’t need no thought control</div>
<div class="paragraph">No dark sarcasm in the classroom</div>
<div class="paragraph">Teachers leave them kids alone</div>
<div class="paragraph">Hey! Teachers! Leave them kids alone!</div>
<div class="paragraph">All in all it’s just another brick in the wall</div>
  
      <script >
const customCursor = document.getElementById("custom-cursor");
const paragraphs = document.querySelectorAll(".paragraph");

function getRandomInt(min, max) {
  const minCeiled = Math.ceil(min);
  const maxFloored = Math.floor(max);
  return Math.floor(Math.random() * (maxFloored - minCeiled) + minCeiled);
}

function updateCursorPosition(x, y) {
  customCursor.style.left = `${x}px`;
  customCursor.style.top = `${y}px`;
}

// Desktop: track mouse movement
document.addEventListener("mousemove&qu.........完整代码请登录后点击上方下载按钮下载查看

网友评论0