Positioning controls with bootstrap not aligning

0

I need to do the following: Label on top and control under the labels. I took the example from the twitter bootstrap page itself and it is not working. Below my code:

<div id="tabs-1">
    <form role="form"><!--A tag ul contem os titulos das abas-->

        <div class="form-group">

            <div class="form-group">
              <label for="txtCnpjPdv" >CNPJ/Razão Social:</label>
              <input type="text" class="form-control;col-sm-2" id="txtCnpjPdv" placeholder="Digite o Cnpj">
            @*</div>

            <div class="form-group">*@
              <label for="txtContato" >Contato:</label>
              <input type="text" class="form-control;col-sm-2" id="txtContato" placeholder="Digite o Cnpj">
            @*</div>*@

            <label for="ddlFiltrarRede" class="col-sm-2 control-label">Filtrar Rede:</label>
            @*<div class="col-sm-3">*@
              <select class="form-control;col-sm-2" name="ddlTipoEvento" id="ddlFiltrarRede" >
                <option value="SemFiltro">Sem Filtro</option>
                <option value="Associativa">Associativa</option>
                <option value="Franquia">Franquia</option>
                <option value="Propria">Própria</option>
              </select>
            @*</div>*@

            <label for="ddlFiltrarStatus" class="col-sm-2 control-label">Filtrar Status:</label>
            @*<div class="col-sm-3">*@
              <select class="form-control;col-sm-2" name="ddlTipoEvento" id="ddlFiltrarStatus" >
                <option value="SemFiltro">Sem Filtro</option>
                <option value="Ok">Ok</option>
                <option value="Atençao">Atenção</option>
                <option value="Erro">Erro</option>
                <option value="NaoCadastrado">Não Cadastrado</option>
                <option value="Desativado">Desativado</option>
              </select>
            @*</div>*@

            <label for="ddlFiltrarVisao" class="col-sm-2 control-label">Visão:</label>
            @*<div class="col-sm-3">*@
              <select class="form-control;col-sm-2" name="ddlTipoEvento" id="ddlFiltrarVisao" >
                <option value="Geral">Geral</option>
                <option value="SouzaCruz">Souza Cruz</option>
              </select>
            @*</div>*@
        </div>
       </div>
</form>
</div>

If I remove this part of the select controls ( class="col-sm-2 control-label" ), it's all on the same line. What I want is label on top and control down.

    
asked by anonymous 25.06.2014 / 19:24

2 answers

2

The problem seems to be in the class attribute of your input , where

class="form-control;col-sm-2"

Change to

class="form-control col-sm-2"

   <form role="form"><!--A tag ul contem os titulos das abas-->

        <div class="form-group">

            <div class="form-group">
              <label for="txtCnpjPdv" >CNPJ/Razão Social:</label>
                <input type="text" class="form-control col-sm-2" id="txtCnpjPdv" placeholder="Digite o Cnpj" />
            </div>

            <div class="form-group">
              <label for="txtContato" >Contato:</label>
                <input type="text" class="form-control col-sm-2" id="txtContato" placeholder="Digite o Cnpj" />
            </div>

            <label for="ddlFiltrarRede" class="col-sm-2 control-label">Filtrar Rede:</label>
            <div class="col-sm-3">
              <select class="form-control col-sm-2" name="ddlTipoEvento" id="ddlFiltrarRede" >
                <option value="SemFiltro">Sem Filtro</option>
                <option value="Associativa">Associativa</option>
                <option value="Franquia">Franquia</option>
                <option value="Propria">Própria</option>
              </select>
            </div>

            <label for="ddlFiltrarStatus" class="col-sm-2 control-label">Filtrar Status:</label>
            <div class="col-sm-3">
              <select class="form-control col-sm-2" name="ddlTipoEvento" id="ddlFiltrarStatus" >
                <option value="SemFiltro">Sem Filtro</option>
                <option value="Ok">Ok</option>
                <option value="Atençao">Atenção</option>
                <option value="Erro">Erro</option>
                <option value="NaoCadastrado">Não Cadastrado</option>
                <option value="Desativado">Desativado</option>
              </select>
            </div>

            <label for="ddlFiltrarVisao" class="col-sm-2 control-label">Visão:</label>
           <div class="col-sm-3">
              <select class="form-control col-sm-2" name="ddlTipoEvento" id="ddlFiltrarVisao" >
                <option value="Geral">Geral</option>
                <option value="SouzaCruz">Souza Cruz</option>
              </select>
           </div>
        </div>

</form>

Example: JSFiddle

EDITED

To position the labels in one row and the controls in another, you need to use a div with class row for each, for example:

<div class="row">
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
         <label for="txtCnpjPdv" >CNPJ/Razão Social:</label>
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
       <label for="txtContato" >Contato:</label>
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
        <label for="ddlFiltrarRede" class="col-sm-2 control-label">Filtrar Rede:</label>
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
        <label for="ddlFiltrarStatus" class="col-sm-2 control-label">Filtrar Status:</label>
    </div>
   <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
        <label for="ddlFiltrarVisao" class="col-sm-2 control-label">Visão:</label>
    </div>
</div>
<div class="row">
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
        <input type="text" class="form-control col-sm-2" id="txtCnpjPdv" placeholder="Digite o Cnpj" />
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
       <input type="text" class="form-control col-sm-2" id="txtContato" placeholder="Digite o Cnpj" />
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
        <select class="form-control col-sm-2" name="ddlTipoEvento" id="ddlFiltrarRede" >
                <option value="SemFiltro">Sem Filtro</option>
                <option value="Associativa">Associativa</option>
                <option value="Franquia">Franquia</option>
                <option value="Propria">Própria</option>
              </select>
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
         <select class="form-control col-sm-2" name="ddlTipoEvento" id="ddlFiltrarStatus" >
                <option value="SemFiltro">Sem Filtro</option>
                <option value="Ok">Ok</option>
                <option value="Atençao">Atenção</option>
                <option value="Erro">Erro</option>
                <option value="NaoCadastrado">Não Cadastrado</option>
                <option value="Desativado">Desativado</option>
              </select>
    </div>
   <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
        <select class="form-control col-sm-2" name="ddlTipoEvento" id="ddlFiltrarVisao" >
                <option value="Geral">Geral</option>
                <option value="SouzaCruz">Souza Cruz</option>
              </select>
    </div>
</div>

Example: JSFiddle

    
25.06.2014 / 19:46
0

The ideal is to take the grid control of the HTML input element and put it in a div structure and always the div with the column control must be inside a div

                             CNPJ / Company Name:                                            ... Other controls to complete GRID 12 columns     

I hope to have helped my friend !!

    
28.04.2017 / 19:37