- Text masking
A Pen by Emadamerho Nefe on CodePen.
A Pen by Emadamerho Nefe on CodePen.
| <div class="masking-container"> | |
| <h1 class="masked-text">Masked Animation</h1> | |
| </div> |
| body { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| height: 100vh; | |
| margin: 0; | |
| background: #222; | |
| font-family: 'Arial', sans-serif; | |
| overflow: hidden; | |
| } | |
| .masked-text { | |
| font-size: 8rem; | |
| font-weight: bold; | |
| color: transparent; | |
| background-image: url('https://images.unsplash.com/photo-1732535725600-f805d8b33c9c?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'); | |
| background-size: 200%; /* Enlarged for smooth animation */ | |
| background-position: 0 50%; | |
| background-clip: text; | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| animation: animate-background 5s infinite alternate linear; | |
| } | |
| @keyframes animate-background { | |
| 0% { | |
| background-position: 0 50%; | |
| } | |
| 100% { | |
| background-position: 100% 50%; | |
| } | |
| } |