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

469
Vistas
css/ js: How to display on click on a button the rest of the paragraph text while being responsive?

I'm trying to display the rest of my text with an animation on the height when you click on a button, I managed to do it but the problem is that I can't find a way to make it responsive.. Basically I display a height: 30px and an overflow: hidden.

And I toggle on a class that contains a height: 300px , it looks good in the mobile version but if I increase the resolution of the page the height will become too small.

I thought there might be a way to adapt the height with the width of the screen, or maybe there is another way to hide part of the text?

Below is the code:

Scss:

.about__body{
    @include displayFlex($direction: column, $align-item: center);
    gap: 20px;
    &-content {
        height: 60px;
        overflow: hidden;
        transition: all 400ms ease-in-out;
    }
}

.about__body-content-show {
    transition: all 400ms ease-in-out;
    height: auto;
}

JS:

let btnAbout = document.getElementById("btn--about")
let contentAbout = document.querySelector(".about__body-content")

const onClickShow = () => {
    btnAbout.addEventListener('click', (e) => {
        e.preventDefault()
        contentAbout.classList.toggle('about__body-content-show')
    })
}
onClickShow()
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You basically can use JS to achieve this and make your container same height as your content

document.getElementById('expand').addEventListener('click', function() {
     document.querySelector('.content-holder').style.height = document.querySelector('.content').offsetHeight + 'px';
     document.querySelector('.content-holder').classList.toggle('collapsed');
});

a working fiddle: https://jsfiddle.net/sdjhetq1/

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