js实现鼠标为聚光灯文字阴影跟随变化效果代码

代码语言:html

所属分类:动画

代码描述:js实现鼠标为聚光灯文字阴影跟随变化效果代码

代码标签: 聚光灯 文字 阴影 跟随 变化 效果

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">




    <style>
        body {
        	margin: 0 auto;
        	cursor: none;
        	overflow: hidden;
        }
        .body {
        	height: 100%;
        	width: 100%;
        	position: absolute;
        	z-index: -1;
        	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100%25' width='100%25'%3E%3Cdefs%3E%3CradialGradient id='grad'%3E%3Cstop offset='0%25' stop-color='rgba(0,0,0,0)' /%3E%3Cstop offset='100%25' stop-color='rgba(0,0,0,1)' /%3E%3C/radialGradient%3E%3C/defs%3E%3Cfilter id='f'%3E%3CfeTurbulence baseFrequency='0.1 0.001' numOctaves='1' seed='1'%3E%3C/feTurbulence%3E%3CfeColorMatrix values='-0.7 -2.2 -2.7 4.6 -3 -0.4 5 2.4 2.9 -4.5 -1.1 -3.8 -0.6 -2.8 -0.8 1.3 -3.3 -4.2 -1.5 0.2'%3E%3C/feColorMatrix%3E%3C/filter%3E%3Crect width='100%25' height='100%25' fill='%23966F33'%3E%3C/rect%3E%3Crect width='100%25' height='100%25' fill='url(%23grad)'%3E%3C/rect%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'%3E%3C/rect%3E%3C/svg%3E");
        }
        .text {
        	font-size: 3em;
        	font-weight: bold;
        	text-align: center;
        	color: #fff;
        	font-family: "Roboto", sans-serif;
        	position: absolute;
        	top: 50%;
        	left: 50%;
        	transform: translate(-50%, -50%);
        	z-index: 2;
        }
        
        .light {
        	position: absolute;
        	transform: translate(-50%, -50%);
        	font-size: 2em;
        	z-index: 2;
        }
    </style>


</head>

<body>
    <!-- spotlights & highlights 💡-->
    <div class="text"> Spotlight</div>
    <div class="body"></div><span class="light">🔦</span>


    <script>
        const longShadow = (
        	theClass,
        	shadowColor = "#111",
        	xMult = 1,
        	yMult = 1,
        	shadowLength = 20
        ) => {
        	let shadow = "";
        	for (l.........完整代码请登录后点击上方下载按钮下载查看

网友评论0