Create an animated, glowing, gradient border with CSS
Inspired by a codepen by Gayane Gasparyan - codepen.io/gayane-gasparyan/p... - I took my own attempt to create a rotating gradient border, including a nice soft glow.
To do it, I use @property, which doesn't have fantastic browser support, but near the end of the video I look at why that's not really a big deal 🙂
🔗 Links
✅ My finished code: codepen.io/kevinpowell/pen/QW...
✅ Codepen that inspired this video: codepen.io/gayane-gasparyan/p...
✅ More on @property on the MDN: developer.mozilla.org/en-US/d...
⌚ Timestamps
00:00 - Introduction
00:22 - The HTML
00:37 - The custom properties and base styles
01:50 - Adding the gradient and glow with pseudo-elements
03:40 - Using @property to make the gradient rotate
05:44 - Switching to a conic-gradient
06:45 - Finishing touches
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZread channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!
Пікірлер: 126
Kevin, This is such a nice format for tutorial. You clearly explained step by step how this works. Thank you
Mind-blown! Thanks, Kelv!
This might just be my favorite CSS Video of all time
I just discovered this! Thank you Kevin for making this tutorial! A lot of people were asking for a tutorial, so I would like to put your video inside the pen, if you don't mind
Ok, I'm baffled. That's really good work!
Great video! Would love to see more tutorials and/or examples of practical, forward progressive applications of @property.
What a gorgeous effect
Kevinn, I loved this video friend! 🤩
Súper !! More videos like this please!! Thankyou!
Thanks Kevin for these fun tutorials. One question I have however is that with majority of traffic coming from mobile devices how can we translate some of these effects to touch based (micro)interactions?
This is so freaking COOL!
Wow! Super Awesome!
You have made CSS truly fun and understandable, thanks.
@SCHTRAM
Жыл бұрын
Also made me want to get back into working as a programmer, but only in UI/Css stuff =D
@okosmik
Жыл бұрын
@@SCHTRAM To dare is to do 😄, just do it, fr.
thanks Kevin, always great
Trully Amazing . I love you !
I just went down the rotating gradient rabbit hole like a month ago. When I saw your title and thumbnail, I was scared you were going to show something I missed 😅. But I got to the angle property point and decided to go in a different direction because of browser support. Keep up the good work! Watching your videos has reignited my interest in front-end developement.
Totally gonna use this idea!
Whenever i watch your video i literally think that why are your videos soo much related to the my problem you are video are very good and the knowledge you provide is literally the nest level thankyou you for providing the knowledge by the way i am from Indian and know ..
As always really helpfull :) I will use it in my projects thanks to you!
Beautiful!
I am learning a lot through your video thankuu
you are always awesome for CSS!!!!!!
I barely know your channel and already benefiting from your videos... I copied your Cool 3d card that follows the mouse movement using JavaScript as part of my training abd learned so much advanced css coding and tricks Just want to say thank you for your enormous efforts and knowledge that ur sharing with us (beginners&students) May allah bless you 😘
You are the best. Good luck ❤
I think even in a square box the gradient rotation would have looked slightly off - to have a constant apparent speed along the outline, you'd probably need a circle.
Amazinggggg
Thank you!!! saw something like this a couple of days ago and was going message you to see if you could do a video on it :)
Thank you! Great video!
thank you sooo much kevin
That was so fun.
amazing content
this is so cool thank u
Thank You🔥🔥🔥
Hey Kevin, great video. Why aren't you going with the unit dvh instead of vh. Just to keep it right and think at the mobiles devices out there. Apart from that, all good as usual.
I love your videos in which you sometimes mistype and ponder. I would like to see more of them again. But maybe that's because I don't belong to the TikTok generation and like to watch you make mistakes. In any case, keep going somehow! Your videos are perfect! A big thank you to you!
more effects and cool animations, please
Thank you for your videos, i started learning code half a year ago and many of your videos taught me alot
@KevinPowell
Жыл бұрын
Thank you so much!
Thanks for your content. BTW, is there any way to have a box with animated, gradient border color when the box itself is half-transparent or maybe a glassmorphism effect ?
I like these shorter style video's where you don't type, but paste! Good job 👍
very cool! Hi sir Kevin, I wonder if you are planning to release another chatgpt content especially after the gpt4 announcement? cheers! 😊
Thanx you sir 👍
once i resolved this making exact the same, but without that property. instead a got 2 div one smaller than the other and the bigger rotating, filled with the colors
I've had something like this, trying to make the center transparent, or to actually have a semi transparent background. Like an RGB animation around a somewhat transparent "screen" where text can be. I've been trying to use it as an alert overlay for streams. Is it ok to play around with your way of doing it to see how it turns out for what I want?
Thanks, maybe this helps. I've seen a codepen of this but it didn't work in my html file for some reason. Didn't even move
does "place-items" not have suggestion "center" for you guys too in VS Code?
Because of you I dont hate front end as much.
In mob&desk app development, of course we need to design the content (background-colors, colors, positions, etc.), So will I need css
Thankyou
Noice
So great ! How to make it animated only when appear in the screen.
Having trouble getting the gradient to render after swapping out the discrete degree value with the @property value. Anyone know why this may be?
Good job Kevin. But could you do it with transparent (card) background? 🤔I bet it would look awesome in glassmorphism, but I was not able to figure it out. EDIT: Never mind, YT just redirected me to your other vieo, where you made glowing border with SVG, so it can be done that way. Its funny, you answered my question, even before I managed to ask it :D
@Jakiita1
Жыл бұрын
Which video is this if you dont mind me asking? Im looking for the exact same thing :O
@Tom-og3fr
Жыл бұрын
@@Jakiita1 its this one kzread.info/dash/bejne/mJeipqSJY86Zcqg.html
Since when did the body start to stretch to the full height of the viewport? It used to be that the html was the full height, and the body was only only as tall as required
That's smart solution! however, However, is there a solution that works across all modern browsers? Tried the link, doesn't work on safari, the border doesn't show at all, let alone the animation
Do all major evergreen browsers support this houdini feature?
I found a neat trick to get another type of animation to work in firefox by pasting the code below just after the one described in the video: @-moz-document url-prefix() { .card::before, .card::after { background: linear-gradient( 45deg, var(--clr-5), var(--clr-4), var(--clr-6), var(--clr-7), var(--clr-5), var(--clr-4), var(--clr-6), var(--clr-7)); background-size: 450% 100%; animation: ffspin 3s linear infinite; } } @keyframes ffspin { 0% { background-position:0%; } 100% { background-position:96%; } } Colors I used: --clr-4: #2d8f85; --clr-5: #38CFD9; --clr-6: #637c54; --clr-7: #4e00c2;
@luischiesa4568
9 ай бұрын
Hey man! I’m new coding and I’m not the best English speaker/reader could you help me to fix this problem with the Firefox I put that and still not working
@NiltonOliv
7 ай бұрын
Thanks friend, you are a genius, before it didn't work on Chrome and also on Firefox. You saved me, very beautiful effect.
Hey Kevin, I really appreciate your videos. I'm having a problem at 2:57 the blur function does not create a shadow around the card but instead it stays contained within the card... Any ideas why that might be happening?
@appsenence9244
Жыл бұрын
Make sure you plar around with the numbers of the size of your container and the blur effect. It doesn't quite work as you would expect it to.
great vid, but do you think Lottie animation would have done better here ? if we had 100 of these, i think it'd be better to switch to lottie rather than rendering css
You're doing great!
@KevinPowell
Жыл бұрын
Thank you!
I did something similar this a weak ago but it is a big headache 'cause .outer-card > . gradient-border > .main-card and for .outer-card:before for blur aah . And I saw that post few days ago and i thought that i can't , and u did it just with a .card 🤯 it's big brain time;
the gradient doesn't work in firefox at all - seems like you should first put the gradient value in root as fallback and put houdini property after root
wonder if we can use border: solid .5rem transparent didnt try tho, so the space there is actually be a "border" tho there is probably background behind the border so wouldnt work wonder if we can make the background start after the border-box
@KevinPowell
Жыл бұрын
Oh, that's a good suggestion! Sadly, what happens is the background of the element actually gets drawn under the border. There are ways around that with `background-clip`, but then you lose the border-radius. I think the best solution is probably a --padding custom property on the parent, and use that for the inset value.
@nomadshiba
Жыл бұрын
@@KevinPowell padding with background-clip works great
Is there anyway of making the border longer just soley verticly as it doesnt span all my text ;-;
I think masking might create a more performant version of this. I’ll post a link if I figure it out.
hot damn
It is possible to fallback to animate the gradient with javascript when @property is not supported?
@KevinPowell
Жыл бұрын
There might even be a polyfill, I haven't looked into it though
Hi, very cool video ! I don't know why when I put a hover transform on the card by following your steps, the pseudoelements go over my card an hide it... I've tried to play with the z-index of the parent but it don't seems to work neither. If someone has any solutions 👌
@0xdeadbabe240
7 ай бұрын
what i found as a solution is that the background-color of the container of .card should have an alpha component closer to zero. this solved it for me.
can we make this only while hovering if yes can any one tell me how
I was working with some after & before but the inset wasn't working and had to do width 100% & top 0 bottom 0, any idea? using beta chrome on Linux
@KevinPowell
Жыл бұрын
was it position relative, and not absolute? Only thing I can think of.
@io1921
8 ай бұрын
any solution to this ?
Sir, I have learnt javascript but the problem is, I don't know where to add javascript on my projects. Please help
Is it necessary to use both ::before and ::after?
@naczelnypsycholog6296
Жыл бұрын
one is blur that give effect of light/shadow and the other is moving solid colors
Hi, im using Styled components and i cant find solution for this part @property --rotate { syntax: ""; initial-value: 132deg; inherits: false; } @keyframes spin { 0% { --rotate: 0deg; } 100% { --rotate: 360deg; } } I also asked chatGPT V4 without positive result :/ Does any1 knows please?
You don’t tell us but is the gradient angle not normally animatable?
Brilliant!!! But Hoodiny is "under construction" for the last 5 years as I remember, or even more. But anyway, it will work without animation. Very good example of graceful degradation. Thank you!
Does not work with Firefox unfortunately, unless you remove the property from the gradient
@khaledsalah9248
Жыл бұрын
that's exactly the problem I ran into, it's so sad.
@issy63ls
Жыл бұрын
Same here, i'm stuck on same problem.. how did you fix it?
@khaledsalah9248
Жыл бұрын
@@issy63ls I think there are 2 fixes, first is to write browser specific code second is to use javascript for the rotating effect of the gradient.
this is one of those "you like it, but it's bad UX so nevermind"
nice I just think that colors pick is not optimal for that kind of effect
Now you just need a script to make the gradient follow the direction that the mouse pointer is, and adjust the brightness based on the distance...
When I'm adding inset: -.5rem and z-index: -1, im loosing the glow effect and an opaque box is coming, can anyone help me out with that?
@io1921
8 ай бұрын
any solution?
@0xdeadbabe240
7 ай бұрын
what i found as a solution is that the background-color of the container of .card should have an alpha component closer to zero. this solved it for me.
I used Bing AI to summarize Houdini CSS. Soon you will be summarized too. I should have pasted your transcript. There will likely be an app to turn any video into a AI KZread Short.
But you still can animate your css var with js
Why is Firefox so far behind on support of these cool features? Can only get it to work with a fallback color. The property does not work and animation neither.
whos the best ha, whos the best - ps. stewie
Could someone help me? I want to put this code at Firefox
@KevinPowell
9 ай бұрын
For now, no way, it's not supported as I did it here.
Present sir
It would be nice to speak to how much CPU (GPU?) it takes for modern browsers to manage some of these more advanced rendering features (blur filter, gradients). The last thing we need are uninformed web developers overusing techniques like these without awareness of how it can impact UX for those viewing websites overloaded with "features" like this. I've visited websites where a simple full screen background blur filter causes my laptop fan to spin up like crazy.
Pretty sure this was inspired by new starter template of Next.js
@KevinPowell
Жыл бұрын
Never even looked at it yet!
for rotating, why did you use houdini instead of just plain ol' rotate: ;
@palantonio8764
Жыл бұрын
nevermind, i might have misunerstood the assignment
@KevinPowell
Жыл бұрын
I looked at what happened at around 3:10 if you tried a rotate, the entire element is rotating around. We need to animate either the angle itself inside the gradient (or you could animate the colors), and to do that we need to use houdini... unless I missed something obvious :D
@palantonio8764
Жыл бұрын
@@KevinPowell yeah, i misunerstood what you wanted to rotate. Love your videos!
OK, now here's the question: add any `animation` to the .card and explain why it breaks...
@KevinPowell
4 ай бұрын
If you're animating, I'm guessing it's a transform? In that case, it's making a new stacking context, so the z-index: -1; on the pseudo-elements no longer goes behind the element.
Kevin, STOPPP.. I was literally looking at Codepens of this! Go to the restroom and see the notification for this video.. SMH spy on cooler people man 😂
How many 3's do you know? 1) 0, 1, 2 2) 1, 2, 3 3) X, Y, Z 4) Red, Green, Blue 5) Red, Yellow, Blue 6) Left, Center, Right 7) Forward, Center, Back 8) Up, Center, Down 9) Dot, Line, Dot = Line 10) Dot, Dot, Dot = Polygon 11) Sun, Earth, Moon 12) Air(Gas/Vapour), Earth(Rock/Soil), Water(Liquid/Solid) = Planet Earth 13) Animals/People of the Air, Animals/People of the Ground, Animals/People of the Water 14) Chariots of the Air/Space, Chariots of the Ground, Chariots of the Water 15) Alpha, Beta, Gamma 16) A, plus, B 17) A, divide, B 18) A, multiple, B 19) A, subtract, B 20) Speed, Distance, Time 21) E, M, C2 22) Force, Mass, Acceleration 23) H, 2, O 24) Light Source, Close Distance, Your Eyes 25) Object1, Object2, Close Distance = Collision/Reflection/Sound/Touch 26) Open Door, Go though the Door, Close the Door 27) Open Car Door, Get In Car, Close Car Door 28) Seconds, Minutes, Hours 29) Days, Months, Years 30) 1st, 2nd, 3rd 31) Gold, Silver, Bronze 32) Grandmother, Mother, Daughter 33) Grandfather, Father, Son 34) Woman, Man, Child 35) In the womb/egg, out of the womb/egg, dead 36) Gay/Lesbian, Straight, Bisexual 37) Nursery School, Primary School, Secondary School 38) The Object is Empty, Fill the Object, Stop Filling the Object(Glass,Tank,Stomach,Bottle etc) 39) Accelerating, Decelerating, Constant 40) Open Lipstick, Put it on, Close Lipstick 41) Lying down, Standing, Moving 42) Left Wing Mirror, Rear View Mirror, Right Wing Mirror 43) God, Angles, Heaven 44) Satan, Demons, Hell 45) God, Adam, Ribcage 46) Adam, Eve, Eden 47) Adam, Eve, Tree of Knowledge 48) Satan, Eve, Tree of Knowledge 49) Judaism, Christianity, Islam 50) Breathe in, Hold breath, Breathe out 51) Close eyes, Stare, Blink 52) Bite, Chew, Swallow 53) Bladder is Empty, Bladder is Full, Start Peeing 54) Intestines are Empty, Intestines are Full, Start Pooping 55) Shoes Off, Shoes On, Shoes Off 56) Sexuality is Empty, Sexuality is Full, Start Sexual Relif 57) Feeling Cold, Okay, Feeling Hot 58) Start, Middle, End 59) Open Schoolbag, Take something out, Close Schoolbag 60) Creation, Infinity, Destruction 61) Minus, Zero, Plus 62) Home, Event(Bowling, Cinema, Park, Party), Home 63) Clear Sky, Partially Cloudy, 100% Cloudy 64) 0%, 50%, 100% 65) Plane On Ground, Plane In Air, Plane on Ground 66) Socks Off, Socks On, Socks Off 67) Heart is beating, Heart has stopped but has been revived, Heart has stopped but cannot be revived 68) Xbox, Playstation, Nintendo 69) Windows, Linux, Mac 70) One Film, Two Films, Three Films 71) One Goal, Two Goals, Three Goals 72) Green Light, Amber Light, Red Light 73) Open Purse, Put something In, Close Purse 74) Touch Key, Press Key, Release Key 75) Home, School, Home 76) Ready, Set, Go 77) 3, 2, 1 = Lift off/New Year/Count down 78) Pick up object, Move object, Put object down 79) Pick up object, Throw object, Object hit ground 80) Hands in water, Hands above water, Hands in water = Front-crawl 81) Head above water, Head in water, Header in water = Breaststroke 82) Hit/Pass/Throw ball, close distance, Hit/Pass/Throw ball = Baseball/Cricket/Hockey/Ice Hockey/Tennis/Rugby 83) Home, Work, Home 84) Bible, Torah, Quran 85) c, c++, c# 86) AMD, .COM, CPU, DVD, GFX, HDD, RAM, ROM, SSD, PSU, WWW. 87) Back-End Developer, Front-End Developer, Full Stack Developer 88) Continents, Islands, Water Bodies 89) Car in Garage, Car out of Garage, Car in Garage 90) Open laptop and turn it on, use laptop, Shutdown laptop and close it 91) Pick up (Crayon, Marker, Paintbrush, Pen, Pencil), move it, Put it down = writing 92) Bad Dream, No Dreams, Good Dream 93) Engaged, Married, Divorced 94) No/short hair, average hair, long hair 95) Jacket on hanger, Jacket on you, Jacket on hanger 96) Hat on surface, Hat on head, Hat on surface 97) Glasses on surface, Glasses on you, Glasses on surface 98) Raw, Cooking, Cooked 99) Out of the Cave, In the Cave, Out of the Cave 100) SSJ1, SSJ2, SSJ3 = DBZ 101) Open drawer, take out/put in, Close drawer 102) It's on, it's off, it's not working = (Car, Mobile Phone, Laptop, TV) 103) It's Awake, it's sleeping/unconscious, it's dead (Animals/People) 104) BMX, Racing Bike, Mountain Bike 105) Allah, God, Yahweh 106) Uranus, Cronus, Zeus 107) Gaia, Rhea, Hera 108) Crassus, Julius Caesar, Pompey 109) Africa, Europe, Asia 110) HTML, CSS, Javascript
Hi sir i have a request for you. There are many people like me who are not native english speakers. It is difficult to understand when you speak fast. If you could speak slower then we can have better understanding
@KevinPowell
Жыл бұрын
This is me talking slower 😂. I really do try. You could show the video down a bit in the video settings
@naczelnypsycholog6296
Жыл бұрын
@@KevinPowell don't do it Kevin, you don't speak fast at all.
@prathamesh9990
Жыл бұрын
@@naczelnypsycholog6296 not everyone understand same accent
@naczelnypsycholog6296
Жыл бұрын
@@prathamesh9990 level up bro, instead of bringing down others ;)
We need a collab with you and @hyperplexed
it dont look anything like what u demoed to start with i got a codepen about cards!
@KevinPowell
Жыл бұрын
What doesn't look the same? My Codepen goes to my finished code, and I think it's closer to the initial one, just with different colors and a slower animation 🤔