I am currently working on a code where I want the background to scroll instead of the text.
This means that the text will stay fixed in its position while the background scrolls behind it on the page.
Any suggestions on how I can achieve this?
For an example, you can check out this CodePen:
body {
margin: 0;
background-color: #000;
}
.page {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.container {
height: 100vh;
width: 100%;
overflow-y: scroll;
}
.content {
display: flex;
justify-content: center;
align-items: center;
height: 250vh;
font-size: 96px;
background: linear-gradient(
#000 0%,
#66458e 40%,
#fff 50%,
#66458e 75%,
#000 100%
);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
background-attachment: fixed;
}
.text {
text-align: center;
}
<div class="page">
<div class="container">
<div class="content">
<h1 class="text">TEST</h1>
</div>
</div>
</div>