Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda