text-shadow keyframes 实现文字抖动

249 阅读1分钟
		<style>
			body {
				margin: 0;
				padding: 0;
				display: flex;
				justify-content: center;
				align-items: center;
				min-height: 100vh;
				background: #000;
			}
			h2 {
				color: yellow;
				font-family: sans-serif;
				font-size: 4em;
				animation: animate 1s linear infinite;
			}

			@keyframes animate {
				0%,
				100% {
					text-shadow: -1.5px -1.5px 0 #0ff, 1.5px 1.5px 0 #f00;
				}
				25% {
					text-shadow: 1.5px 1.5px 0 #0ff, -1.5px -1.5px 0 #f00;
				}
				50% {
					text-shadow: 1.5px -1.5px 0 #0ff, 1.5px -1.5px 0 #f00;
				}
				75% {
					text-shadow: -1.5px 1.5px 0 #0ff, -1.5px 1.5px 0 #f00;
				}
			}
		</style>
	</head>
	<body>
		<h2>jiujueismmp</h2>
	</body>