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

257
Views
Aleatorización de ubicaciones de css con JavaScript

Debería aleatorizar la ubicación de un círculo negro cuando se presiona, pero no puedo entender por qué no funciona.

 function myFunction1(button) { var xPosition = math.floor(math.random() * 101) + '%'; button.style.top = xPosition; var yPosition = math.floor(math.random() * 101) + '%'; button.style.left = yPosition; }
 .circle { width: 100px; height: 100px; background-color: red; border-radius: 50%; } .black { background-color: black; }
 <button type="button" class="black circle" onclick="myFunction1(this)"></button>

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

0

Prueba esto:

Cambiar matemáticas... a Matemáticas ...

Y agrega esto a css:

 .circle { ... position: fixed; }

Como esto:

 function myFunction1(button) { var xPosition = Math.floor(Math.random() * 101) + '%'; button.style.top = xPosition; var yPosition = Math.floor(Math.random() * 101) + '%'; button.style.left = yPosition; }
 .circle { width: 100px; height: 100px; background-color: red; border-radius: 50%; position: fixed; } .black { background-color: black; }
 <button type="button" class="black circle" onclick="myFunction1(this)"></button>

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!