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

142
Views
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 answers
Answer question

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 Report

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 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!