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

175
Views
Imagen de centrado con alineación central que choca con Posición en CSS

Soy nuevo en html y css y recientemente comencé a hacer un juego de lienzo. Deseo tener una imagen y alinearla en el centro del lienzo con HTML. Usé la propiedad 'posición: Absoluta' y al menos pude ponerla en el lienzo, pero cuando usé la propiedad 'text-align: center', mi propiedad de posición dejó de funcionar y quedó debajo del lienzo.

Así que quería saber cómo puedo centrar mi imagen en el lienzo.

CSS

 #startgameimg{ text-align:center; width: 50px; display:block; margin:auto; position: absolute; cursor: pointer; }

HTML

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>GAME</title> <link href = "style.css" rel = "stylesheet"> </head> <body> <div style = "text-align: center;"> <canvas id = "canvas" height = "560" width = "800" style = "border:5px solid rgb(33, 8, 61)" >Your Browser is Not Supported</canvas> <div id = 'start'> <img src = "play.png" alt = "" id = "startgameimg"/> </div> </div> <script src = "script.js" ></script> </body> </html>

Tenga en cuenta: revisé entre 5 y 6 preguntas de desbordamiento de pila sobre el mismo tema, pero no pude encontrar ninguna solución

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

0

 #startgameimg{ text-align:center; width: auto; display:block; margin:auto; position: absolute; cursor: pointer; top:50%; left:50%; transform:translate(-50%, -50%) }
 <div style = "text-align: center; position: reletive"> <canvas id = "canvas" height = "560" width = "800" style = "border:5px solid rgb(33, 8, 61)" >Your Browser is Not Supported</canvas> <div id = 'start'> <img src = "play.png" alt = "MY IMG" id = "startgameimg"/> </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!