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

165
Views
Animación básica HTML y CSS

Así que solo soy un principiante y solo estoy tratando de descifrar las animaciones y cómo funcionan.

Mi plan es mover la pelota infinitamente en un número infinito de grados (digamos 90) en una línea. Aquí hay un par de problemas que me preguntaba:

  1. ¿Hay una mejor manera de usar clases que tienen reglas comunes y ligeramente diferentes (que tienen diferentes rotaciones)?
  2. ¿Cómo puedo hacer que el movimiento de la pelota en las nuevas líneas tenga diferentes rotaciones?

 .line, .line-deg90 { background-color: hsl(0, 0%, 0%); height: 3px; width: 400px; position: absolute; top: 50%; left: 50%; margin: 0 0 0 -200px; transform-origin: 50%; } .line-deg90 { transform: rotate(90deg); } .ball { background-color: hsl(0, 0%, 0%); height: 30px; width: 30px; border-radius: 50%; position: absolute; top: -15px; left: 0; animation: move 2s infinite alternate ease-in-out; } @keyframes move { 0% { left: 0px; top: -15px; } 100% { left: 370px; top: -15px; }
 <div class="line"> <div class="ball"></div> <div class="line-deg90"></div>

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Aquí hay una idea usando variables CSS para tener un código genérico. Simplemente ajuste el ángulo y el desplazamiento para controlar el movimiento.

 .ball { --angle: 0deg; --offset: 150px; background-color: hsl(0, 0%, 0%); height: 30px; width: 30px; border-radius: 50%; position: absolute; inset: 0; margin: auto; animation: move 2s infinite alternate ease-in-out; } @keyframes move { 0% { transform: rotate(var(--angle)) translate(var(--offset)) } 100% { transform: rotate(var(--angle)) translate(calc(-1*var(--offset))) } } html { min-height:100%; background: linear-gradient(red 0 0) center/100% 2px, linear-gradient(red 0 0) center/2px 100%; background-repeat:no-repeat; }
 <div class="ball"></div> <div class="ball" style="--angle:90deg;--offset:100px"></div>

over 4 years ago · Santiago Trujillo 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!