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

98
Visualizações
Transition max-height of div in relation to its max-width

I'm pretty new to HTML, CSS and JS and right know I do a project for school. So I have a timeline with years on it and everytime you click on the year a box expands with information in it. My problem now is that it always expand to its max-width but I want that the div is in a specific ratio. (tried aspect-ratio but didnt work)

Here is the following code

JS:

$('.box2').each(function() {
    var $this = $(this);
    
    function toggleActive() {
        $('.bigbox2').toggleClass('bigbox2').children('.content');  
    }

    $this.click(function() {
        if (!$(this).hasClass('bigbox2') ) { 
            toggleActive();       
        }
        $this.toggleClass('bigbox2').children('.content');
    }) 
}) 
body {
    margin: 0;
    background: #222;
    font-family: Impact;
}

.row2 {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: left;
    gap: 50px;
    position:absolute; top:10px;left:5px;
}

.box2 {
    position: relative; left: 50px;
    overflow: hidden;
    border-radius: 30px;
    background: white;
    padding: 10px;
    color: black;
    font-family: Arial, Helvetica, sans-serif;
    text-align: left;
    max-height: 25px;
    max-width: 55px;
    transition-duration: 200ms;
    transition-delay: 1ms;
    transition: max-width 0.5s ease 0s, max-height 0.5s ease 0s;
    transition-timing-function: ease;
}

.box2.bigbox2 {
    max-width: 700px;
    max-height: 1000px;

}

.box2 h2 {
    margin-top: 0px;
    text-align: right;
}
<div class="right"></div>
    <div class="line"></div>
<div class="row2">
        <div class="box2">
            <h2 class="title">2010</h2>
            <div class="content">
                <div>
                    <p>sjdfhasjdfsjkfhs dsdfh asjkdfhasjkdf hsajkdfhasdkjfhaskjfd hasjfd hasjfkhaslkdfjashkdjfhasfkjh sdjkf 
                        hasjkfhsajkfhsakfhasjkdfhasjkdfasjkfahsfjk asj hsaj hasdj fhasjkdf hasjk hfsakjfhasklfhaslfkjashdfjksadhfjsahfjsjkfafhsdfjkalsfh 
                        as sajfsjk</p>
                </div>
            </div>
            
        </div>
    </div>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

So here is an example and I want like that it uses more height than width, but its using always so whole width.

Thanks already!!

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