Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JoshOohAhhAi/cafcd3b33b7c40e61e65f5950e193c07 to your computer and use it in GitHub Desktop.
Save JoshOohAhhAi/cafcd3b33b7c40e61e65f5950e193c07 to your computer and use it in GitHub Desktop.
Animated repeating linear gradient
<div class="laser"></div>
body {
padding-top: 15em;
margin: 0;
background-color: black;
overflow: hidden;
}
@keyframes projectileAnimation {
0% {
background-position: 0 0;
}
100% {
background-position: -100% 0;
}
}
.laser {
--player-color: yellow;
position: absolute;
width: 90%;
height: 4px;
background: repeating-linear-gradient(
to right,
transparent,
var(--player-color) 5%,
transparent 5%,
transparent 10%
);
background-size: 200% 100%; /* Double the width for smooth looping */
background-repeat: repeat-x;
pointer-events: none;
animation: projectileAnimation 2s linear infinite; /* Adjust animation duration as needed */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment