Any CSS Wizards? Gradient Animation around Pseudo Element
I have a pseudo element on my header/navigation & a gradient animation div - I am having trouble figuring out how to make the gradient animation div continue to look like it goes around the pseudo element.
My initial thoughts were that I could create a pseudo element on the .gradient-border itself the same shape/slightly larger but I'm not too sure how that would work utilising border-top etc to get the shape & how I can make the animation effect look like it goes from left to right around the pseudo element.
This is what the header:after element looks like:
This is the gradient div animation:
4 Replies
i tink itll be better if u make a codepen
Can see here on dev preview: https://6v6c3kfpi1pxzxhm-55004168434.shopifypreview.com
My first try would be a
clip-path
on the .gradient-border
. You'd want to have position: absolute
The height is 5px right now, so I'd give it a height that's 5px taller than the white part that sticks down. Then add something like this:
The calcs in here are a guess and owuld need some tweaking.Worked perfectly! Thank you so much, I didn't even think of using a clip-path (also didn't expect a response from the css god himself!). Managed to tweak the calcs and get it to a point where I was happy with 🙂
Also a note for anyone who finds this in future, had an issue where it was positioning to the far right and I was confused why. It was because the animation/width was set to 3000px (changed it to width: 100% & the keyframes to 0%/100% and it worked)