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

230
Visualizações
CSS :hover don't apply if style is set in JS

first time posting a question so sorry if I make mistakes.

I have the following JS code for creating "notes" with a specified rotation:

newNote.style.transform = rotate(30deg);

it works great but when I try to use this CSS it does not get applied (should reset the rotation):

.notes:hover{transform: none;}

so after some more trying I think it could be a bug as styling never apply on hover if they been applied in the JS (is there any fix for this or should it be reported as a bug?)

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Using !important can help you. Example:

.notes:hover{transform: none !important;}
about 4 years ago · Juan Pablo Isaza Relatório

0

Please remove your js code and use these instead:

.notes { transform: rotate(30deg); }
.notes:hover{transform: none;}

The first line adds the rotation always.

If you want to add rotation in specific case, use these styles instead:

.notes.rotate { transform: rotate(30deg); }
.notes:hover{transform: none;}

In your js, add 'rotate' class to the element you need:

newNote.classList.add('rotate');

It will add the rotation.

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