Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Hacer una animación css usando una máscara de degradado transparente

Actualmente estoy haciendo una animación que aplicará una máscara de degradado en una imagen. La máscara es una máscara transparente y se transformará de derecha a izquierda de la imagen. Aquí está mi código.

 <!DOCTYPE html> <html> <head> <style> .container { height: 100vh; width: 100vw; background-color: white; position: relative; } .first { background-image: url('https://i.ibb.co/17zzm7P/flower.jpg'); background-size:cover; position: absolute; height: 100%; width: 100%; -webkit-mask-image: linear-gradient(to left, transparent 0px, black 20rem, black); -webkit-animation: rightToLeft 5s forwards; } @keyframes rightToLeft { 0% { -webkit-mask-position: 100vw 0%; mask-position: 100vw 0%; } 100% { -webkit-mask-position: 0vw 0vw; mask-position: 0vw 0vw; } } </style> </head> <body> <div class="container"> <div id="first" class="first"> </div> </div> </body> </html>

Básicamente, la animación funciona bien. Sin embargo, la imagen de la máscara solo se aplica a un área específica cuando se mueve de derecha a izquierda. Debido a que la máscara es transparente, espero que cuando se mueva a la nueva área, el área anterior por la que pasó también sea transparente. ¿Cómo puedo hacer para que el área anterior también sea transparente?

Imagen de máscara Muchísimas gracias por su tiempo.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Estás casi bien, solo necesitas deshabilitar la repetición usando mask-repeat: no-repeat

 .container { height: 100vh; background-color: white; position: relative; } .first { background-image: url('https://i.ibb.co/17zzm7P/flower.jpg'); background-size: cover; position: absolute; height: 100%; width: 100%; -webkit-mask-image: linear-gradient(to left, transparent, black 20rem); -webkit-mask-repeat: no-repeat; -webkit-animation: rightToLeft 5s forwards; } @keyframes rightToLeft { 0% { -webkit-mask-position: 100vw 0%; mask-position: 100vw 0%; } 100% { -webkit-mask-position: 0vw 0vw; mask-position: 0vw 0vw; } } body { margin:0; }
 <div class="container"> <div id="first" class="first"> </div> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!