A Pen by Motionharvest on CodePen.
Created
October 10, 2024 23:50
-
-
Save JoshOohAhhAi/cafcd3b33b7c40e61e65f5950e193c07 to your computer and use it in GitHub Desktop.
Animated repeating linear gradient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="laser"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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