Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

44
Vistas
Horizontal Scroll Problem - No elements off

There is an unwanted horizontal scroll on my website and I can't figure out why. I have a simple header that uses display: flex, justify-content: center, marin-top: 5vh and a padding on the logo and the burger. Further down it has a title that does translate-x: 1em to 0em when loading from the right, a text that does the same from the left and an image that does it again from the right. Screenshot from my Webpage

Code:

// Loading animation
loading = document.querySelectorAll(".loading");

window.onload = function(element) {
  loading.forEach((link) => {
    link.classList.add("loaded");
  });
};
.title {
  opacity: 0;
  transform: translateX(-2em);
  transition: transform 3s 0.5s cubic-bezier(0, 1, 0.3, 1), opacity 0.3s 0.5s ease-out;
  will-change: transform, opacity;
}

.title.loaded {
  opacity: 1;
  transform: translateX(0em);
}

.text {
  opacity: 0;
  transform: translateX(-4em);
  transition: transform 4s cubic-bezier(0, 1, 0.3, 1), opacity 0.3s 0.5s ease-out;
  will-change: transform, opacity;
}

.text.loaded {
  opacity: 1;
  transform: translateX(0);
}

.hero-image {
  opacity: 0;
  transform: translateX(1em);
  transition: transform 1s 0.5s cubic-bezier(0, 1, 0.3, 1), opacity 0.1s 0.5s ease-out;
  will-change: transform, opacity;
}

.hero-image.loaded {
  transform: translateX(0em);
  opacity: 1;
}

.mobile-hero {
  opacity: 0;
  transform: translateX(1em);
  transition: transform 1s 0.5s cubic-bezier(0, 1, 0.3, 1), opacity 0.1s 0.5s ease-out;
  will-change: transform, opacity;
}

.mobile-hero.loaded {
  transform: translateX(0);
  opacity: 1;
}
<div class="mobile">
  <div>
    <h1 class="title loading">Michael Nussbaum</h1>
    <p class="text bottom loading">Zeit ist relativ, Zeit ist Geld</p>
  </div>
  <img src="img/daniel-portrait.png" class="mobile-hero loading" />
</div>

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm not entirely sure if this is what you're after, but if you want to stop horizontal overflow on a page you should be able to use this code:

body {
  overflow-x: hidden;
}

I don't work with animated elements a lot, but I would imagine that the translateX is causing the unwanted scroll, which the overflow-x should help. Hope this helped :)

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos