How to have two checkbox components inside a Row with a title

Asked

Viewed 169 times

2

I’m a beginner in HTML/CSS/Bootstrap and I have a question about how to put two checkbox components in some type of container with a title. Am I doing it the right way or is there a better way to do it? My components are like this:

inserir a descrição da imagem aqui

But I’d like them to stay that way:

inserir a descrição da imagem aqui

<div class="panel">
    <div class="panel-body container-fluid pt-10 pl-15 pr-15">
        <div class="form-horizontal">
            <vc:summary />
            <div class="form-horizontal">
                <div class="col-md-12">
                    <div class="form-group row">
                        <div class="col-md-6">
                            <label asp-for="Descricao" class="control-label">Descrição</label>
                            <input asp-for="Descricao" class="form-control text-uppercase" />
                            <span asp-validation-for="Descricao" class="text-danger"></span>
                        </div>
                        <label class="control-label">Aplicar a:</label>
                        <div class="col-md-3">
                            <div class="float-left mr-20">
                                <input type="checkbox" class="mycheckbox" data-plugin="switchery"
                                       checked />
                            </div>
                            <label class="pt-3" for="inputBasicOn">Pessoa Física</label>
                        </div>
                        <div class="col-md-3">
                            <div class="float-left mr-20">
                                <input type="checkbox" class="mycheckbox" data-plugin="switchery"
                                       checked />
                            </div>
                            <label class="pt-3" for="inputBasicOn">Pessoa Jurídica</label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

I know it must be a very simple procedure, but I don’t know how to do it in the best way possible. Someone would know how to help me fix?

A hug to all!

  • Which version of bootstrap?

  • Hi @hugocsl! v3.3.7 :)

  • Has duplicate id’s: id="mycheckbox"

  • Ah tah, disregard them... I made changes and removed them... I will update the post. I’m Sorry rssr

1 answer

1


Your image template looks like it has more CSS styles than the normal Bootstrap pattern, but anyway I made this template that can help you.

The trick here is to separate the chackbox and the label of him in a div, and in the last column where it will not have the "title" on the input you let the label without content like a &nbsp; and resolves. I don’t really like this kind of solution, but as it is a framework sometimes this type of solution solves without major problems.

Look how it turned out. Display in "Whole Page" tb to see a better result.

  <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

    <div class="panel">
        <div class="panel-body container-fluid pt-10 pl-15 pr-15">
            <div class="form-horizontal">
               
                <div class="form-horizontal">
                    <div class="col-md-12">
                        <div class="form-group row">
                            <div class="col-md-6">
                                <label asp-for="Descricao" class="control-label">Descrição</label>
                                <input asp-for="Descricao" class="form-control text-uppercase" />
                                <span asp-validation-for="Descricao" class="text-danger"></span>
                            </div>
                            <div class="col-md-3">
                              <label class="control-label">Aplicar a:</label>
                                  <div>
                                  
                                    <input type="checkbox" class="mycheckbox" data-plugin="switchery"
                                    checked />
                                    <label class="pt-3" for="inputBasicOn">Pessoa Física</label>
                                  </div>
                              </div>
                              <div class="col-md-3">
                                <label class="control-label" style="color: transparent">&nbsp;</label>
                                <div>
                                  <input type="checkbox" class="mycheckbox" data-plugin="switchery" checked />
                                  <label class="pt-3" for="inputBasicOn">Pessoa Jurídica</label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

  • 1

    Thanks @hugocsl !!!!! It worked ball show. As I don’t know very well from the Front End part, I’m using a framework called Remark which is very good. You can style a lot of things without having to create a lot of CSS’s with rsrssrsr Thanks for the help! :)

  • @Masterjr cool that worked out there. Framework is to be used even rss, This Remark looks interesting I will seek to know more about it tb

  • It’s really good @hugocsl!!! You’ll like it!!!

Browser other questions tagged

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