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

133
Views
Is there a way to use position and/or offset instead of CSS3 rotation without transforming children?

I have a div that is centered using this css:

#r0 {
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    transform-origin: center;
}

And this div is being rotated using this:

$('#r0').css('transform', 'rotateZ(' + xxx + 'deg)');

But I need to append other divs to this div, but setting transform property on this div mispositions those divs and causes unwanted transformations on them, which is natural behavior for them. My question is that is there another way to rotate this div, for example, using top and left, or any other method that wouldn't affect appended children?

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

0

Create an inner div within that div with an opposite transform property:

<div id="r0">
  <div id="r0-inner">
    ...
  </div>
</div>

and you can negate the rotation with:

$('#r0').css('transform', 'rotateZ(' + xxx + 'deg)');
$('#r0-inner').css('transform', 'rotateZ(-' + xxx + 'deg)');

You can go a step further using CSS variables to shorten your JS to only one line of code:

#r0 {
  --rotation: 0deg;
  transform: rotateZ(var(--rotation));
}

#r0-inner {
  transform: rotateZ(calc(var(--rotation) * -1));
}
$('#r0').css('--rotation', xxx + 'deg');
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!