Text scroll and hover effect with
Hey there, You are most welcome to this article. I hope you will enjoy this article. If you like this article then please share this article with your friends and colleagues. If you have any questions or suggestions regarding this article then please comment down below.
๐Table Of Content
- Text scroll and hover effect Project Folder Structure
- Text scroll and hover effect HTML CODE
- Text scroll and hover effect CSS CODE
- Text scroll and hover effect Javascript Code
Project Folder Structure:
- Create a file called index.html to serve as the main file.
- Create a file called style.css for the CSS code.
- Create a file called script.js for the JavaScript code.
Text scroll and hover effect HTML CODE
<div class="container"> <h1 class="text">TEXT EFFECT<span>WOAH</span></h1> <h1 class="text">GSAP<span>AND CLIPPING</span></h1> <h1 class="text">CRAZYYY<span>CRAZYYY</span></h1> <h1 class="text">HOVER ON ME<span><a href="https://stacksorted.com/text-effects/minh-pham" target="_blank">SOURCE</a></span></h1> <h1 class="text">LIKE THIS?<span><a href="https://twitter.com/juxtopposed" target="_blank">LET'S CONNECT</a></span></h1> </div>
Text scroll and hover effect CSS CODE
body {
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
background-color: #0D0D0D;
margin: 10%;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
height: 60vh;
}
.text {
font-size: 7.5vw;
letter-spacing: -.01em;
line-height: 100%;
margin: 0;
width: 100%;
color: rgb(182, 182, 182, 0.2);
background: linear-gradient(to right, #b6b6b6, #b6b6b6) no-repeat;
-webkit-background-clip: text;
background-clip: text;
background-size: 0%;
transition: background-size cubic-bezier(.1,.5,.5,1) 0.5s;
border-bottom: 1px solid #2F2B28;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
position: relative;
}
span {
position: absolute;
width: 100%;
height: 100%;
background-color: #4246ce;
color: #0D0D0D;
clip-path: polygon(0 50%, 100% 50%, 100% 50%, 0 50%);
transform-origin: center;
transition: all cubic-bezier(.1,.5,.5,1) 0.4s;
display: flex;
flex-direction: column;
justify-content: center;
}
.text:hover > span {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
}
a {
text-decoration: none;
color: inherit;
}
Text scroll and hover effect JavaScript CODE
gsap.registerPlugin(ScrollTrigger);
const textElements = gsap.utils.toArray('.text');
textElements.forEach(text => {
gsap.to(text, {
backgroundSize: '100%',
ease: 'none',
scrollTrigger: {
trigger: text,
start: 'center 80%',
end: 'center 20%',
scrub: true,
},
});
});
Live Preview Of Text scroll and hover effect
See the Pen Text scroll and hover effect with GSAP and clip by Codewithshobhit (@Codewithshobhit) on CodePen.
How to run this Html Css and Js Project in Our Browser?
first, you need a code editor either you can use VS code studio or notepad and then copy the html,css, and javascript code, create separate or different files for coding then combine them, after creating file just click .html file or run from VS Code studio and you can project preview.
Which Code Editor do you use to create those projects?
I am using VS Code Studio.
is this project responsive or not?
Yes! this project is a responsive project.
If you enjoyed reading this post and have found it useful for you, then please give share it with your friends, and follow me to get updates on my upcoming posts. You can connect with me on Instagram
if you have any confusion Comment below or you can contact us by filling out our Contact Us form from the home section. ๐ค๐

No comments:
Post a Comment