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

169
Visualizações
Nuxt dynamicly appended elements ignoring styling

I've run into an issue where elements that get appended with Javascript ignore all styling.

In this specific case I've got buttons where I want to have ripple effects uppon clicking the code works as following:

I got elements in my HTML with the class material-button

After the elements are loaded the following code will be executed:

mounted() {
// To make sure the code runs after the elements are rendered i used $nextTick
  this.$nextTick(() => {
    function createRipple(event) {
      const button = event.currentTarget;
      const circle = document.createElement("span");
      const diameter = Math.max(button.clientWidth, button.clientHeight);
      const radius = diameter / 2;

      circle.style.width = circle.style.height = `${diameter}px`;
      circle.style.left = `${event.clientX - (button.offsetLeft + radius)}px`;
      circle.style.top = `${event.clientY - (button.offsetTop + radius)}px`;
      circle.classList.add("ripple"); 

      const ripple = button.getElementsByClassName("ripple")[0];

      if (ripple) {
        ripple.remove();
      }

      button.appendChild(circle);
    }

    const buttons = document.querySelectorAll(".material-button");
    for (const button of buttons) {
      button.addEventListener("click", createRipple);
    }
  })
}

I thought it was because the styling was inside a scoped <style> tag so I tried the following things:

  • I added the styling to a <style> tag without the scope attribute to my component
  • I added the styling to a <style> tag without the scope attribute to my default.vue
  • I added the styling to my global.scss

None of these attempts have worked for me. I'm pretty sure however that the styling is indeed ignored and that my problem is not caused somewhere else, because the ripple element is infact appended as proven by this screenshot:

enter image description here

However i can see that span.ripple is nowhere to be found in the styling:

enter image description here

about 4 years ago · Juan Pablo Isaza
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