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

118
Visualizações
How can I add units to a Transform CSS Property with jQuery?

I am making a simple vertical carousel of elements using jQuery, it's all ready but I have a problem with the Transform property because working with him its a little weird. I display de code for more understanding:

let element_height = $(".faq-carousel li.visible").outerHeight(true) + 5;

$(".faq-carousel li").css("transition", "transform 0.5s")
$(".faq-carousel li").css("transform", "translateY(-" + element_height + "px)" );

setTimeout( function() {
$(".faq-carousel li").css( { transition: "none" } ) }, 500 );

$(".faq-carousel li.visible").removeClass('visible').next().addClass('visible')

It's a simple problem, but I can't find the way to add px to the "translateY()". They replace the old px with the new ones and it does not move almost.

If you know a solution I will be very thankful!!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found a better solution, i will share it to help those who are looking for something similar:

let carousel_height = 0;

  $("#faq_carousel_arrow_down").click(function(e) {

    let element_height = $(".faq-carousel li.visible").outerHeight(true) + 5;
    carousel_height += parseInt(element_height);

    $(".faq-carousel li").css("transition", "transform 0.5s")

    $(".faq-carousel li").css("transform", "matrix(1, 0, 0, 1, 0, -" + carousel_height + ")" );

    $(".faq-carousel li.visible").removeClass('visible').next().addClass('visible')

    e.preventDefault();
  });

And the HTML:

<ul class="faq-carousel">
  <li class="item shadow t1 visible">
    <div>
    </div>
  </li>
  <li class="item shadow t2">
    <div>
    </div>
  </li>
</ul>
<a href="#" id="faq_carousel_arrow_down"><i class="fas fa-angle-down"></i></a>
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