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:
.header:after {
position: absolute;
content: "";
z-index: 10;
left: 50%;
bottom: -20%;
color: #000 !important;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
border-top: 20px solid #fffcf8;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
-webkit-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
height: 0;
opacity: 1;
width: 250px;
}
.header:after {
position: absolute;
content: "";
z-index: 10;
left: 50%;
bottom: -20%;
color: #000 !important;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
border-top: 20px solid #fffcf8;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
-webkit-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
height: 0;
opacity: 1;
width: 250px;
}
This is the gradient div animation:
.seperator-wrapper {
width: 100%;
}
.seperator {
width: 3000px;
height: 5px;
animation: rotate 5s infinite linear;
-webkit-animation: rotate 5s infinite linear;
}

@-webkit-keyframes rotate {
from {
background-position: -3000px;
}
to {
background-position: 0px;
}
}

@keyframes rotate {
from {
background-position: -3000px;
}
to {
background-position: 0px;
}
}

.gradient-border {
background: rgb(247,150,45); /* Old browsers */
background: -moz-linear-gradient(left, #F7962D 0%, #D83E7A 33%, #62308B 66%, #F7962D 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#F7962D), color-stop(33%,#D83E7A), color-stop(66%,#62308B), color-stop(100%,#F7962D)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* IE10+ */
background: linear-gradient(to right, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F7962D', endColorstr='#F7962D',GradientType=1 ); /* IE6-9 */
}
.seperator-wrapper {
width: 100%;
}
.seperator {
width: 3000px;
height: 5px;
animation: rotate 5s infinite linear;
-webkit-animation: rotate 5s infinite linear;
}

@-webkit-keyframes rotate {
from {
background-position: -3000px;
}
to {
background-position: 0px;
}
}

@keyframes rotate {
from {
background-position: -3000px;
}
to {
background-position: 0px;
}
}

.gradient-border {
background: rgb(247,150,45); /* Old browsers */
background: -moz-linear-gradient(left, #F7962D 0%, #D83E7A 33%, #62308B 66%, #F7962D 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#F7962D), color-stop(33%,#D83E7A), color-stop(66%,#62308B), color-stop(100%,#F7962D)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* IE10+ */
background: linear-gradient(to right, #F7962D 0%,#D83E7A 33%,#62308B 66%,#F7962D 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F7962D', endColorstr='#F7962D',GradientType=1 ); /* IE6-9 */
}
No description
4 Replies
glutonium
glutonium•13mo ago
i tink itll be better if u make a codepen
AdsyC
AdsyCOP•13mo ago
Kevin Powell
Kevin Powell•13mo ago
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:
clip-path: polygon(0 0, 100% 0, 100% 5px, calc(50% + 135px) 5px, calc(50% + 125px) 100%, calc(50% - 125px) 100%, calc(50% - 135px) 5px, 0 5px);
clip-path: polygon(0 0, 100% 0, 100% 5px, calc(50% + 135px) 5px, calc(50% + 125px) 100%, calc(50% - 125px) 100%, calc(50% - 135px) 5px, 0 5px);
The calcs in here are a guess and owuld need some tweaking.
AdsyC
AdsyCOP•13mo ago
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)
No description
Want results from more Discord servers?
Add your server