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

289
Visualizações
How to resize multiple divs at the same time smoothly when hover over each one using jquery

What I want to do is

increase the width of the div that gets hovered over and equally decrease the width of the other 3 divs.

So if "div1" get hovered over, then "div1" width needs to be "40%"

and

the other 3 divs widths would go to "20%" which would equal 100%

This works with the code I have, but its not smooth and when I hover fast over multiple divs everything goes haywire. It's very buggy

What am I doing wrong?

Link of what I'm trying to do: https://constructlar.atakansaracoglu.com/

My HTML:

<div class="container">
   <div class="div1">
   </div><div class="div2">
   </div><div class="div3">
   </div><div class="div4">
   </div>
</div>

My CSS:

.container div {
   position: relative;
   display: inline-block;
   width: 25%;
}

My Script:

$(document).ready(function(){
  $('.container div').hover(function(){
     let $this = $(this);
     $this.siblings().animate({
       'width' : '19%'
     },200);
     $this.delay(200).animate({
       'width' :'40%'
     },300);
  });
});
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Using CSS and transition property instead of jQuery makes the page smoother.

.container div {
   position: relative;
   display: inline-block;
   width: 25%;
   height: 100px;
   transition: width 0.4s;
}

.container:hover div {
    width: 20%;
}

.container div:hover {
    width: 40%;
}
<div class="container">
   <div class="div1" style="background:red">
   </div><div class="div2" style="background:cyan">
   </div><div class="div3" style="background:yellow">
   </div><div class="div4" style="background:green">
   </div>
</div>

about 4 years ago · Santiago Trujillo 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