A Pen by Tim Wilson on CodePen.
Created
January 3, 2024 14:43
-
-
Save taskylizard/39959cf774b97d938e94da0144e5fe18 to your computer and use it in GitHub Desktop.
CSS God Rays
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
<main> | |
<div class="relative flex flex-col h-[100vh] items-center justify-center bg-white dark:bg-black transition-bg"> | |
<div class="absolute inset-0 overflow-hidden"> | |
<div class="jumbo absolute -inset-[10px] opacity-50"></div> | |
</div> | |
<h1 class="relative flex items-center text-5xl font-bold text-gray-800 dark:text-white dark:opacity-80 transition-colors"> | |
charm | |
<span class="ml-1 rounded-xl bg-current p-2 text-[0.7em] leading-none"> | |
<span class="text-white dark:text-black">UI</span> | |
</span> | |
</h1> | |
<div class="mt-4"> | |
<button onclick="toggleTheme()" class="px-3 py-1 border border-stone-200 rounded-full drop-shadow-sm text-sm text-stone-800 dark:text-white bg-white/40 dark:bg-black/40 backdrop-blur-lg hover:border-stone-300 transition-colors dark:border-stone-500 dark:hover:border-stone-400">Toggle Theme</button> | |
</div> | |
</div> | |
</main> |
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
function toggleTheme() { | |
if (document.body.classList.contains("dark")) | |
document.body.classList.remove("dark"); | |
else | |
document.body.classList.add("dark"); | |
} |
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
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap'); | |
body { | |
font-family: Inter, sans-serif; | |
} | |
@keyframes jumbo { | |
from { | |
background-position: 50% 50%, 50% 50%; | |
} | |
to { | |
background-position: 350% 50%, 350% 50%; | |
} | |
} | |
.jumbo { | |
--stripes: repeating-linear-gradient( | |
100deg, | |
#fff 0%, | |
#fff 7%, | |
transparent 10%, | |
transparent 12%, | |
#fff 16% | |
); | |
--stripesDark: repeating-linear-gradient( | |
100deg, | |
#000 0%, | |
#000 7%, | |
transparent 10%, | |
transparent 12%, | |
#000 16% | |
); | |
--rainbow: repeating-linear-gradient( | |
100deg, | |
#60a5fa 10%, | |
#e879f9 15%, | |
#60a5fa 20%, | |
#5eead4 25%, | |
#60a5fa 30% | |
); | |
background-image: var(--stripes), var(--rainbow); | |
background-size: 300%, 200%; | |
background-position: 50% 50%, 50% 50%; | |
filter: blur(10px) invert(100%); | |
mask-image: radial-gradient(ellipse at 100% 0%, black 40%, transparent 70%); | |
pointer-events: none; | |
} | |
.jumbo::after { | |
content: ""; | |
position: absolute; | |
inset: 0; | |
background-image: var(--stripes), var(--rainbow); | |
background-size: 200%, 100%; | |
animation: jumbo 60s linear infinite; | |
background-attachment: fixed; | |
mix-blend-mode: difference; | |
} | |
.dark .jumbo { | |
background-image: var(--stripesDark), var(--rainbow); | |
filter: blur(10px) opacity(50%) saturate(200%); | |
} | |
.dark .jumbo::after { | |
background-image: var(--stripesDark), var(--rainbow); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment