Alignment of elements per line

Asked

Viewed 44 times

0

I’m trying to align the elements, but without success. The idea is to limit per line only 8 elements, besides not happening that, still keeps returning error: inserir a descrição da imagem aqui

Misaligned elements:

inserir a descrição da imagem aqui

Codes:

Html:

<div class="col-lg-12">
        <div class="box">
            <div class="box-header">
                <i class="fa fa-eye"></i>
                <h3 class="box-title">
                    Eventos por Operador
                </h3>

            </div>
            <div class="box-body" id="bolhas">
             <!-- Carregar os elementos do JavaScript aqui -->
                </div>
            <div class="overlay">
                <i class="fa fa-refresh fa-spin"></i>
            </div>



        </div>

    </div>

Javascript:

function PreencherBolhas(){
    $.ajax({
        async: false,
        type: 'GET',
        url: '/Developer/GetContadoresOperadoresEventos',
        success: function (data) {
            var linha = "<div class='col-lg-6' style='padding-right:0px;'>";
            var row = "<div class='col-lg-6' style='padding-right:0px;'>";
            for (var i = 0; i < data.length; i++) {
                var temp = data[i];
                linha += "<div class='col-lg-3'>";
                linha += "<div class='small-box bg-yellow'>";
                linha += "<div class='inner'>";
                linha += "</div>";
                linha += "</div>";
                linha += "<h2 style='margin-left: 2.5vw;'>" + temp.percentual + " %" +  "</h2>";
                linha += "<p style='color: black'>" + temp.dsNome + "</p>";
                linha += "</div>";
            }
            linha += "</div>";
            var html = document.getElementById('bolhas');
            var box = document.getElementsByClassName('col-lg-12');
            html.innerHTML = linha;
            document.box.appendChild(html);
        }
    });
}

Anyway I don’t know how to fix, if someone can guide me.

  • 2

    Igor doesn’t get 8 per line that you’re putting col-lg-3, This way they will be 4 per row even, because 3+3+3+3 = 12 that is the limit of columns of the Bootstrap Grid! Even you can only divide the columns into multiples of 12 logo 8 per column is not possible, because 8/12 vc would need a col-lg-1,5 what does not exist... I think you will have to organize your items differently

  • 1

    The error you fix by changing the line to box[0].appendChild(html);.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.