In this tutorial I will show you how to create an underline animation on scroll.
I will show you two different methods, that results in two slightly different animations.
With the first method, the underline is directly anchored to the scrolling. It plays back and forth, as you scroll up and down.
With method 2, the animation is very similar to an entrance animation: it plays out smoothly, only one time, when the element enters the viewport.
See both of them here:
Features:
- Choose your own colors and styling
- Adjust the animation precisely
- Choice of two different animation styles
- Method 1 uses the Scrolling Effects from Elementor Pro
Let's get started!
Method 1. Elementor Underline on Scroll
This is a premium tutorial. Purchase access to unlock the full tutorial.
11 Responses
Hi
Is it possible with dotted underline on scroll?
Hey Veslemoy!
Sorry, this is not really possible as we have things now as we are using scaleX for the animation, so it would not look as you expect.
With further custom work though it's possible, but above the intended scope of the tutorial.
Hi Maxime
Can I change the background-color to a gradient? Will the underline work with background-image: linear-gradient ?
Thanks
Christian
Please ignore. Gradient underline works beautifully.
Best
Christian
Awesome Christian!
Glad to know you made it work.
Just let me know if there is anything!
Cheers!
Hi Maxime
Just wondering if it is possible to create a rounded left and right edge to the underline (like your button below)?
My guess is border-radius will not work. Could there be a workaround to create a rounded underline?
thanks !
Greetings Christian!
Yes border radius should work fine here. You will probably want to remove any skew in that case.
Let me know if you have problems wih it.
Cheers!
Hi again Maxime
Quick question on this CSS:
I'm using the underline on different Headings on this page https://wblstage.wpengine.com/
I want each Heading to underline with different colours. I'm using this CSS on each Heading but they all change to the same colour because it's the same Class. If I add an ID for each Heading how can I add the ID to the CSS? Would it be:
#heading-one.underline-on-scroll .... etc ?
Thanks
/* Code from https://element.how/elementor-underline-on-scroll-animation/
* Copyright 2022 Element.How
* Licensed for personal and client use for customers who purchased access
* No redistribution or resale allowed
*/
.underline-on-scroll span {
display: inline-block;
z-index: 7;
text-decoration: none;
/* transform:skew(-0deg); Skew the underline, optional. Can be deleted or adjusted */
padding: 1px;
position: relative;
}
.underline-on-scroll span:before{
content: '';
position: absolute;
width: 100%;
height: 50%; /* How thick the underline is */
z-index: -1;
border-radius: 50px;
left: 0;
bottom: -18%; /* Might need to be adjusted to position the underline */
background-image: linear-gradient(to right, #FF2514, #FFA100); /* Underline color */
transform: scaleX(var(--scale));
transform-origin: 0 50%; /* If you want the underline from right to left, change to 100% 50%. If you want the underline from the center, change to 50% 50%.*/
}
/* Disable the default Elementor animation, don't change */
.underline-on-scroll .elementor-motion-effects-element {
transform: none!important;
}
Greetings Christian,
In that case, use this code, added to each heading > Advanced > Custom CSS field.
This will give you individual control on the color.
You will also need the other CSS, only one time on the page.
Cheers!
Thanks Maxime
I'm guessing this code will override the colours in the original code?
Cheers!
Yes indeed.