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

250
Views
¿Cómo muevo un elemento en diagonal y después de otra animación en jQuery?

Tengo un elemento HTML/CSS:

 <div id="box"> <p> BOX </p> </div> #box { width: 100px; height: 200px; background-color: skyblue; position: absolute; left: 0px; top: 200px; text-align: center; font-family: Times New Roman; }

Necesito que se mueva desde su posición en el medio de la página en diagonal hacia abajo y hacia la izquierda (hacia la esquina izquierda). He intentado esto:

 $(function() { $("button").click(function() { $("#box").animate({ left: $(window).width() - 200 bottom: $(window).width() - 200 } }); });

¿Cómo hago esto con jQuery y lo hago después de que haya estado en la página unos segundos (para que ocurra primero una animación diferente)?

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

0

Considera lo siguiente.

 $(function() { $("button").click(function() { $("#box").animate({ left: $(window).width() - 100, top: $(window).height() - 200 }); }); });
 #box { width: 100px; height: 200px; background-color: skyblue; position: absolute; left: 0px; top: 40px; text-align: center; font-family: Times New Roman; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="box"> <p>BOX</p> </div> <button>Go</button>

Estabas usando la propiedad de width para ambos. Debes usar width y height . También es mejor usar top versus bottom en este caso. Puede usar bottom , pero sugeriría algo como:

 bottom: $("#box").height()

De esta forma, la propiedad de la top será N Pixels desde la "Inferior".

Ver más: https://www.w3schools.com/cssref/pr_pos_bottom.asp

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!