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

449
Visualizações
Why 'transition-duration' effect doesn't work on 'justify-content' or 'left, right' positioning?

let ball,
  startEnd;

function startCal() {
  //variables
  ball = document.getElementById('ball');
  startEnd = document.getElementById('start-end');


  startEnd.style.justifyContent = "flex-end";

  // the background color of the ball is will be rgb(33 250 18)
  ball.style.backgroundColor = "#0ee71f ";

  // the new value of onclick attribute of start-end button 
  // is will be endCal() func
  startEnd.setAttribute('onclick', 'endCal()');

}

function endCal() {
  //variables
  ball = document.getElementById('ball');
  startEnd = document.getElementById('start-end');

  startEnd.style.justifyContent = "flex-start";

  // the background color of the ball is will be red
  ball.style.backgroundColor = "red";

  // the new value of onclick attribute is will be startCal()
  startEnd = document.getElementById('start-end');
  startEnd.setAttribute('onclick', 'startCal()');

}
.o-c {
  width: 385px;
  height: 30px;
  display: flex;
  justify-content: flex-end;
}

#start-end {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 30px;
  width: 65px;
  background: black;
  cursor: pointer;
  border-radius: 250px;
}

#ball {
  /* left: 0;
    display: block; */
  transition-duration: 2s;
  width: 25px;
  height: 25px;
  background: red;
  border-radius: 100%;
}
<div class="o-c">
  <div id="start-end" onclick="startCal()">
    <div id="ball" class="open"></div>
  </div>
</div>

I want the ball to pass slowly, but the effect only works on color change. Why? Can't be used in transition events? I also tried the right and left values, but it didn't work. Someone said set a default value for left value like 'left:0' but in that case only color changed.

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