Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
CSS to put the game player in its position

I'm making a game using React.js, and the player element is a simple image with sprite images implemented in CSS:

.player {
    position: absolute;
    height: 32px;
    width: 32px;
    object-fit: none;
    transform-origin: 50% 50%;
    transform: scale(calc(var(--factor) / 2)) rotate(0.02deg);
    image-rendering: pixelated;
}

How would I add the translate() function to make the player's top left corner exactly at (0, 0)?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you want to be all the way at the top, no matter what else is on the page, position it absolute. This ignores everything up to the next highest positioned element That means it has a position other than the default. You can do that like this.

position: absolute;
top: 0;
left: 0;
/// You might need to adjust for your transform here though

oops... just saw that you already had it absolute. You were 90% of the way there.

about 4 years ago · Juan Pablo Isaza Denunciar

0

For this .player needs a wrapped element with position: relative, and we don't need transform-origin or transform styles:

.parentOfPlayer {
  position: relative;
}

.player {
  position: absolute;
  top: 0;
  left: 0;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda