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

260
Visualizações
¿Por qué no hay suficiente espacio para que quepan las palabras en esta animación?

Estoy tratando de mostrar una animación de texto que pasa en la página de inicio de mi sitio web.

Hay dos textos que deben aparecer. "has venido al lugar correcto" y "nos preocupamos por ti", junto al texto de bienvenida.

Por alguna razón, así es como se ve: ingrese la descripción de la imagen aquí

¡Quiero la bienvenida! el texto aparecerá seguido rápidamente por la primera cita, después de unos segundos, la bienvenida y la primera cita debería desaparecer y la segunda cita debería aparecer.

CSS

 /* animation welcome text styling */ .intro{ display: inline-block; white-space:nowrap; overflow: hidden; } .intro1 { animation: showup 7s infinite; font-family: Arial, Helvetica, sans-serif; font-size:35px; color: purple; } .intro2 { font-size:30px; animation: reveal 7s infinite; width:400px; } .sub-head { margin-left:-355px; animation: slidein 7s infinite; font-size:30px; font-family:Arial, Helvetica, sans-serif; width: 100px; background-color: darkolivegreen; } @keyframes showup { 0% {opacity:0;} 20% {opacity:1;} 80% {opacity:1;} 100% {opacity:0;} } @keyframes slidein { 0% { margin-left:-800px; } 20% { margin-left:-600px; } 35% { margin-left:0px; } 100% { margin-left:0px; } } @keyframes reveal { 0% {opacity:0;width:0px;} 20% {opacity:1;width:0px;} 30% {width:355px;} 80% {opacity:1;} 100% {opacity:0;width:355px;} } /* end of text animation */

HTML:

 <div class= "first-box"> <!-- a welcome text is placed here to grasp the users' attention to the website. --> <div class="intro intro1">Welcome!</div> <div class="intro intro2"> <span class="sub-head "> You've come to the right place</span> <span class="sub-head inactive">We care about you </span> </div> </div>

JS:

 // sets the interval for which the function will run, in this case 8 seconds, (8000) setInterval(function() { // grab all elements with class 'sub-head' and stores it in the elems const. const elems = document.querySelectorAll('.sub-head') elems.forEach(e => { // check if the element has a class 'inactive', if there is one, remove it if (e.classList.contains('inactive')) e.classList.remove('inactive') // if not, add it. This is how it creates a loop. else e.classList.add('inactive'); }); }, 8000)
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Intente agregar una clase inactive y establezca el ancho en 455 (en la revelación de @keyframes reveal ):

 setInterval(function() { const elems = document.querySelectorAll('.sub-head') elems.forEach(e => { if (e.classList.contains('inactive')) e.classList.remove('inactive') else e.classList.add('inactive'); }); }, 8000)
 .intro{ display: inline-block; white-space:nowrap; overflow: hidden; } .intro1 { animation: showup 7s infinite; font-family: Arial, Helvetica, sans-serif; font-size:35px; color: purple; } .intro2 { font-size:30px; animation: reveal 7s infinite; width:400px; } .inactive { display: none; } .sub-head { margin-left:-5px; animation: slidein 7s infinite; font-size:30px; font-family:Arial, Helvetica, sans-serif; width: 200px; background-color: darkolivegreen; } @keyframes showup { 0% {opacity:0;} 20% {opacity:1;} 80% {opacity:1;} 100% {opacity:0;} } @keyframes slidein { 0% { margin-left:-800px; } 20% { margin-left:-600px; } 35% { margin-left:0px; } 100% { margin-left:0px; } } @keyframes reveal { 0% {opacity:0;width:0px;} 20% {opacity:1;width:0px;} 30% {width:455px;} 80% {opacity:1;} 100% {opacity:0;width:455px;} }
 <div class= "first-box"> <div class="intro intro1">Welcome!</div> <div class="intro intro2"> <span class="sub-head "> You've come to the right place</span> <span class="sub-head inactive">We care about you </span> </div> </div>

about 4 years ago · Juan Pablo Isaza Relatório

0

hacer algunos cambios

 const timeout = 15000 const elems = document.querySelectorAll('.sub-head') //for each slide make equal times const forEachSlide = timeout / elems.length const intro1 = document.querySelector('.intro1') const intro2 = document.querySelector('.intro2') //change timeouts of intros (also can set in the css file) intro1.style.animationDuration = `${timeout}ms` intro1.style.animationIterationCount = 'infinite' intro2.style.animationDuration = `${timeout/2}ms` intro2.style.animationIterationCount = 'infinite' //timeout of each '.inactive'changes let showId = setTimeout(function blockShow(){ elems.forEach(e => { if (e.classList.contains('inactive')) { e.classList.remove('inactive') } else e.classList.add('inactive'); }); showId = setTimeout(blockShow, forEachSlide) }, forEachSlide)
 .intro{ display: inline-block; white-space:nowrap; overflow: hidden; } .intro1 { animation-name: showup; font-family: Arial, Helvetica, sans-serif; font-size:35px; color: purple; } .intro2 { font-size:30px; animation-name: reveal; /*width auto makes the block size of this content so all words fit in it*/ width:auto; /*max-width makes maximum width of block where words can be placed*/ max-width: 1000px; } .sub-head{ display: none; } .sub-head.inactive { display: inline-block; margin-left:-355px; animation: slidein 7s infinite; font-size:30px; font-family:Arial, Helvetica, sans-serif; width: 100%; } @keyframes showup { 0% {opacity:0;} 20% {opacity:1;} 80% {opacity:1;} 100% {opacity:0;} } @keyframes slidein { 0% { margin-left:-800px; } 20% { margin-left:-600px; } 35% { margin-left:0px; } 100% { margin-left:0px; } } @keyframes reveal { 0% {opacity:0;width:0px;} 20% {opacity:1;width:0px;} 30% {width:auto;} 80% {opacity:1;} 100% {opacity:0;width:auto;} }
 <div class= "first-box"> <div class="intro intro1">Welcome!</div> <div class="intro intro2"> <span class="sub-head "> You've come to the right place</span> <span class="sub-head inactive">We care about you </span> </div> </div>

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