JQuery - ScrollBar

4

I'm developing a scroll bar in JQuery for an element, a div , I need the bar to be the right size to scroll, I'm posting the code with the error to see if you can help me: / p>

CodePen

The bar is not responsive, I tried to use $( window ).width() in the measurement but it did not work.

    
asked by anonymous 30.05.2016 / 16:04

1 answer

1

Would that be it? link

function barra() {
    var larguraVisivel = $(".conteudo").width();
    var larguraTotal = $(".conteudo2").width();

    var perc = larguraVisivel / larguraTotal;
    var tamanho = larguraVisivel * perc;

    var left = $(".conteudo").scrollLeft() * perc;
    $(".barra1").css('margin-left', left);
    $( ".barra1" ).width(tamanho);
}
    
02.06.2016 / 13:42