1
How to align inputs with the label
Good afternoon, I have a dynamic form, it is done using Bootstrap and the inputs/Labels
is according to the database data, everything is correct, but in the inputs
are getting below the Label
and not next door as it was supposed to be.
Jquery that builds my form
$.getJSON($('#base-url').val() + '/atleta/get_input_area_avaliar',
function(data) {
for (var i=0; i < data.length; i++) {
form += '<div class=\"col-md-12\">';
if(i == 0 || data[i]['descricao_tecnica'] != data[i-1]['descricao_tecnica']){
form += '<p style=\"font-weight: bold; font-size:18px; background-color: #0D80BF; color:white;\" class=\"text-center\"><span>'+data[i]['descricao_tecnica']+'</span></p>';
}
form += '<div><label for=\"'+data[i]['cod_area_avaliar_item']+'\">'+data[i]['descricao_item']+':</label></div>';
form += '<select style=\"width:65px;\" class=\"form-control\" id=\"item_'+ data[i]['cod_area_avaliar_item'] +'\" name=\"item_'+ data[i]['cod_area_avaliar_item'] +'\">';
form += '<option value=\"--\" disabled selected>---</option>';
form += '<option value=\"10\">10</option>';
form += '<option value=\"9\">9</option>';
form += '<option value=\"8\">8</option>';
form += '<option value=\"7\">7</option>';
form += '<option value=\"6\">6</option>';
form += '<option value=\"5\">5</option>';
form += '<option value=\"4\">4</option>';
form += '<option value=\"3\">3</option>';
form += '<option value=\"2\">2</option>';
form += '<option value=\"1\">1</option>';
form += '</select>';
form += '<br>';
form += '</div>';
}
$('#frmNovaAvaliacao #inputs_avaliacao').html(form);
});
HTML where the form is inserted
<div id="frmAvaliacaoItem" style="overflow-y: auto;" class="modal fade" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<form onsubmit="salvar_area_avaliacao_item(); return false;" style="margin-bottom:0">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"></h3>
</div>
<div class="modal-body">
<div class="alert" style="display:none;"></div>
<div class="col-md-12">
<input id="cod_area_avaliar_item" type="hidden" name="cod_area_avaliar_item" value="null"/>
<div class="col-md-12">
<label for="descricao">Descrição</label>
<input type="text" class="form-control" name="descricao" id="descricao" required/>
</div>
</div>
<div class="col-md-12">
<br>
<table id="tbl-area_avaliar_item" class="table table-sm table-hover">
<thead>
<tr>
<th scope="col">Tipo de avaliação técnica</th>
<th scope="col">Descrição</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type='submit' class='btn btn-primary'>Salvar</button>
</div>
</div>
</div>
</form>
</div>
HTML Rendering
I’m not using css
external, only bootstrap
<div id="frmNovaAvaliacao" style="overflow-y: auto; display: block;" class="modal fade in" role="dialog" aria-hidden="false">
<div class="modal-dialog" role="document">
<form class="form-horizontal" onsubmit="salva_avaliacao(); return false;" style="margin-bottom:0">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"></h3>
</div>
<div class="modal-body">
<div class="col-md-12" style="margin-bottom:30px;">
<input style="float:right; border-radius:2px" type="text" name="data_avaliacao" id="data_avaliacao" placeholder="dd/mm/yyyy"> </div>
<input id="cod_escola" type="hidden" name="cod_escola" value="301">
<input id="cod_atleta_area_avaliar" type="hidden" name="cod_atleta_area_avaliar" value="0">
<input id="cod_atleta" type="hidden" name="cod_atleta" value="353">
<!-- Montar formulario pelo JS -->
<div id="inputs_avaliacao_hidden"></div>
<div id="inputs_avaliacao">
<div class="col-md-12">
<p style="font-weight: bold; font-size:18px; background-color: #0D80BF; color:white;" class="text-center"><span>Aspecto Fisico</span></p>
<label for="45">Velocidade:</label>
<select style="width:65px;" class="form-control" id="item_45" name="item_45">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="20">Força:</label>
<select style="width:65px;" class="form-control" id="item_20" name="item_20">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="19">Biotipo:</label>
<select style="width:65px;" class="form-control" id="item_19" name="item_19">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<p style="font-weight: bold; font-size:18px; background-color: #0D80BF; color:white;" class="text-center"><span>Habilidade motora</span></p>
<label for="52">Condução/controle de bola:</label>
<select style="width:65px;" class="form-control" id="item_52" name="item_52">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="53">Desarme:</label>
<select style="width:65px;" class="form-control" id="item_53" name="item_53">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="55">Passe:</label>
<select style="width:65px;" class="form-control" id="item_55" name="item_55">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="56">Drible:</label>
<select style="width:65px;" class="form-control" id="item_56" name="item_56">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="57">Chute:</label>
<select style="width:65px;" class="form-control" id="item_57" name="item_57">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="58">Cabeceio:</label>
<select style="width:65px;" class="form-control" id="item_58" name="item_58">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<p style="font-weight: bold; font-size:18px; background-color: #0D80BF; color:white;" class="text-center"><span>Inteligencia de jogo</span></p>
<label for="23">Tomada de decisão:</label>
<select style="width:65px;" class="form-control" id="item_23" name="item_23">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="51">Tática individual:</label>
<select style="width:65px;" class="form-control" id="item_51" name="item_51">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="22">Criatividade:</label>
<select style="width:65px;" class="form-control" id="item_22" name="item_22">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="28">Liderança:</label>
<select style="width:65px;" class="form-control" id="item_28" name="item_28">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="50">Competitividade:</label>
<select style="width:65px;" class="form-control" id="item_50" name="item_50">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<p style="font-weight: bold; font-size:18px; background-color: #0D80BF; color:white;" class="text-center"><span>Teste de avaliacao</span></p>
<label for="62">Item 2:</label>
<select style="width:65px;" class="form-control" id="item_62" name="item_62">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
<div class="col-md-12">
<label for="63">Item 1:</label>
<select style="width:65px;" class="form-control" id="item_63" name="item_63">
<option value="--" disabled="" selected="">---</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
<br>
</div>
</div>
<p style="font-weight: bold;">Legenda: </p>
<p style="font-size:12px;"> <em>(10)</em> Excelente A - <em>(9)</em> Excelente B - <em>(8)</em> Bom A - <em>(7)</em> Bom B - <em>(6)</em> Regular A - <em>(5)</em> Regular B - <em>(4)</em> Fraco A - <em>(3)</em> Fraci B - <em>(2)</em> Péssimo A - <em>(1)</em> Péssimo B </p>
<div class="form-group" style="margin: 30px 0 30px 0;">
<p style="font-weight: bold; font-size:18px; background-color: #0D80BF; color:white;" class="text-center"><span>Relatório aprovação/reprovação</span></p>
<textarea class="form-control" rows="5" id="relatorio" name="relatorio"></textarea>
</div>
<br>
<div class="col-md-12">
<div class="row">
<div class="col-md-6">
<label for="treinador">Treinador</label>
<input type="text" class="form-control" name="treinador" id="treinador"> </div>
<div class="col-md-6">
<label for="preparador">Preparador Fisico</label>
<input type="text" class="form-control" name="preparador" id="preparador"> </div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<label for="supervisor">Supervisor</label>
<input type="text" class="form-control" name="supervisor" id="supervisor"> </div>
<div class="col-md-6">
<label for="coordenador">Coordenador Técnico</label>
<input type="text" class="form-control" name="coordenador" id="coordenador"> </div>
</div>
</div>
</div>
<br>
<div class="modal-footer" style="margin-top:20%;">
<button id="btn_salvar_avaliacao" type="submit" class="btn btn-primary">Salvar</button>
</div>
</div>
</form>
</div>
I’ve removed the div, but to no avail :(
– Guilherme Rigotti
By inspecting, select is occupying 100%, but I can not decrease it.
– Guilherme Rigotti
@Guilhermerigotti already know what it is, I’ll edit it’s in the Bootstrap documentation including
– hugocsl
I had already removed the div friend, but without success !
– Guilherme Rigotti
@Guilhermerigotti see the Edit link
– hugocsl
I had already added the tags
form-inline
but unsuccessfully, I’m testing it on my computer screen and it’s still wrong :(, label fields are taking up little space, select fields are taking up all their space even though they are small, maybe that’s why he broke the line. How could I resize theseselect
– Guilherme Rigotti
@Guilhermerigotti cara copies the HTML code as it appears in the Browser, from a Ctrl+U and takes the already rendered code and pastes it in your question, include tb what you have of CSS, just so it will give you an accurate answer...
– hugocsl
Remember that they also have the
forms horizontais
who also leave theinput
on the same line as thelabel
. All that remains is whether you want them all on one line or each double label-input on your line.– fernandosavio
I corrected now when I saw your comment in the other reply. hahah
– fernandosavio
@fernandosavio Boa
– hugocsl
@fernandosavio Each double `label/input' on a line. I edited the question as requested @hugocsl
– Guilherme Rigotti
There @hugocsl, is the horizontal form itself. Just edit the example and run to the hug
– fernandosavio
@fernandosavio I removed the
form-control
and with theform-horizontal
I did, however, get theselect
became small and lost the bootstrap style.– Guilherme Rigotti
If you read the documentation Linkei in the comment above you will see that the class
.form-horizontal
shall be placed in the<form>
while the class.form-control
should be placed in the<input>
,<textarea>
and<select>
.– fernandosavio
When I put the class on
form-horizontal
in the form andform-control
usselect
. It doesn’t work.– Guilherme Rigotti
@Guilhermerigotti looks at Edit 2, can help you solve the situation...
– hugocsl
@fernandosavio think it does not work because some elements need to be direct children of others, what does not happen in his structure...
– hugocsl