Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda