Text Opener Animation Using HTML CSS And JS
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
- Project Folder Structure of Text Opener Animation
- Text Opener Animation HTML CODE
- Text Opener Animation CSS CODE
- Text Opener Animation Javascript CODE
- Live Preview of Text Opener Animation
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 Opener Animation HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Opener By CODEWITHSHOBHIT</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- <div class="main-p"></div> -->
<div id="main">
<div id="top">
<h1 id="top-h1">SHOBHIT</h1>
</div>
<div id="center">
<div class="content">
<h4>SHOBHIT</h4>
<h3><i>Love</i> You Guys<i> Follow </i> Me For More</h3>
<div class="btn">
<h5>Such Content</h5>
</div>
<h2>Comment "Text Opener" For Source Code</h2>
</div>
</div>
<div id="bottom">
<h1 id="bottom-h1">SHOBHIT</h1>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/gsap.min.js" integrity="sha512-cOH8ndwGgPo+K7pTvMrqYbmI8u8k6Sho3js0gOqVWTmQMlLIi6TbqGWRTpf1ga8ci9H3iPsvDLr4X7xwhC/+DQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/ScrollTrigger.min.js" integrity="sha512-AMl4wfwAmDM1lsQvVBBRHYENn1FR8cfOTpt8QVbb/P55mYOdahHD4LmHM1W55pNe3j/3od8ELzPf/8eNkkjISQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="script.js"></script>
</body>
</html>
Text Opener Animation CSS CODE
@font-face {
font-family: Founder;
src: urlundefinedFoundersGroteskCondensed-Bold.ttf);
}
@font-face {
font-family: CardinalR;
src: urlundefinedcardinalfruitweb-regular.ttf);
}
@font-face {
font-family: Cardinali;
src: urlundefinedcardinalfruitweb-italic.ttf);
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body{
width: 100%;
height: 100%;
}
.main-p{
width: 100%;
height: 100vh;
background-color: rgbundefined61, 61, 61);
}
#main{
position: relative;
width: 100%;
height: 100vh;
background-color: aquamarine;
overflow: hidden;
}
#top{
position: absolute;
top: 0%;
width: 100%;
height: 50vh;
background-color: rgbundefined255, 255, 255);
z-index: 9;
overflow: hidden;
}
#center{
position: relative;
width: 100%;
height: 100vh;
transform-origin: center;
background-color: rgbundefined0, 0, 0);
transition: all cubic-bezierundefined0.19, 1, 0.22, 1)1s;
overflow: hidden;
}
#bottom{
position: absolute;
bottom: 0;
width: 100%;
height: 50vh;
background-color: rgbundefined255, 255, 255);
overflow: hidden;
}
#main h1{
font-family: Founder;
font-size: 20vw;
position: absolute;
top: 50%;
left: 50%;
transform: translateundefined-50%, -50%);
}
#top-h1{
bottom: 50%;
}
#bottom-h1{
top: 0% !important;
}
.content{
margin-top: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
color: #fff;
gap: 4vh;
}
.content h4{
font-size: 1vw;
font-family: Founder;
}
.content h3{
width: 22%;
font-size: 3vw;
font-family: CardinalR;
text-align: center;
font-weight: 400;
}
.content .btn{
display: flex;
align-items: center;
justify-content: center;
width: 7vw;
height: 2vw;
border-radius: 50px;
background-color: #fff;
color: #0d0d0d;
font-family: Founder;
}
.content h2{
font-size: 5vw;
font-family: Founder;
}
Text Opener Animation Javascript CODE
var tl = gsap.timelineundefined{scrollTrigger:{
trigger:"#main",
// markers:true,
start:"50% 50%",
end:"150% 50%",
scrub:2,
pin:true
}});
tl
.toundefined"#center",{
height: "100vh",
},'a')
.toundefined"#top",{
top: "-50%",
},'a')
.toundefined"#bottom",{
bottom: "-50%",
},'a')
.toundefined"#top-h1",{
top: "60%"
},'a')
.toundefined"#bottom-h1",{
bottom: "-30%"
},'a')
.toundefined"#center-h1",{
top: "-30%"
},'a')
.toundefined".content",{
delay: -0.2,
marginTop: "0%"
})
Live Preview of Text Opener Animation
See the Pen Text Opener Animation Using HTML CSS And JS 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