Align controls with bootstrap

Asked

Viewed 210 times

-1

I have this view

@{
    ViewBag.Title = "ExcelFinancing";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <style>
        .embaixo {
            position: absolute;
            left: 0;
            bottom: 20%;
            width: auto;
            bottom: auto;
            top: 50%;
            margin: 10%,10%,10%,10%;
        }

        radio .btn,
        .radio-inline .btn {
            padding-left: 2em;
            min-width: 7em;
        }



        .radio label,
        .radio-inline label {
            text-align: left;
        }

    </style>
</head>
<body>
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header fa-align-center">@ViewBag.TitlePage</h3>
        </div>
    </div>

    @*<div class="panel panel-default">*@

    @using (Html.BeginForm("geraExcel1", "FinancingReport", FormMethod.Post))
    {
        <div class="form-group">

            <div class="col-md-1">
                @Html.Label("De")
            </div>

            <div class="col-md-3">
                @Html.EditorFor(model => model.dataIni, new { htmlAttributes = new { @class = "form-control", ID = "dataIni" } })
                @Html.ValidationMessageFor(model => model.dataIni, "", new { @class = "text-danger" })
            </div>

            <div class="col-md-1">
                @Html.Label("Até")
            </div>
            <div class="col-md-3">
                @Html.EditorFor(model => model.dataFim, new { htmlAttributes = new { @class = "form-control", ID = "dataFim" } })
                @Html.ValidationMessageFor(model => model.dataFim, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="well well-sm col-md-10">

            <div class="form-group">
                <div class="radio">
                    <label class="btn btn-default">
                        @Html.RadioButton("gender", "Male", true, new { id = "IsMale", name="status", value="Todos" })
                        Todos
                    </label>
                </div>
            </div>

            <div class="form-group">
                <div class="radio">
                    <label class="btn btn-default">
                        @Html.RadioButton("gender", "Female", new { id = "IsFemale", name = "status", value = "Ativo" })
                        Ativo
                    </label>
                </div>
            </div>

            <div class="form-group">
                <div class="radio">
                    <label class="btn btn-default">
                        @Html.RadioButton("gender", "Female", new { id = "IsFemale", name = "status", value = "Inativo" })
                        Inativo
                    </label>
                </div>
            </div>
        </div>

       <div class="form-group">
        <div class="input-group-btn">
            <input type="submit" value="Gerar Relatório" class="btn btn-primary" />
        </div>
       </div>

            }

    </body>
</html>

I changed the view code to that code. The whole question is this: 1) The Submit button is staying on top of the radiobuttons and next to the calendars.

2) Radiobuttons are not giving distance between them and calendars.

See the screenshot below inserir a descrição da imagem aqui

  • Run what? Wouldn’t it be better to post the HTML code already as it is rendered on the page than the ASP code. The way it is you limit a lot of people who can answer you. And which version of Bootstrap you are using the 3 or the 4 ?

  • @hugocsl, how do I get already rendered? Using browser debug? Copy that code and post?

  • That’s right young, take that code and the CSS you used, and say the Bootstrap version. I think this will help you a lot to get an answer faster, after all with your code it is not possible to simulate your problem to help you. Even a screen print with the tb problem would be very useful in this type of question

1 answer

1

To use the Bootsrap Grid you must follow some rules of the documentation as you can see here: https://getbootstrap.com/docs/3.3/css/#grid If you do not follow the "manual" there is no way your Grid will be right...

Notice that you must need one .container to encompass the content, and then you need to separate your content groups into .ROWwhich in turn must be inside their columns col-md-* for you not to have problems of responsiveness after.

Adjusting these details in the Grid your layout will look as expected and as you can see below.

.embaixo {
    position: absolute;
    left: 0;
    bottom: 20%;
    width: auto;
    /* bottom: auto; */
    top: 50%;
    margin: 10%,10%,10%,10%;
}

.radio .btn,
.radio-inline .btn {
    padding-left: 2em;
    min-width: 7em;
}



.radio label,
.radio-inline label {
    text-align: left;
}
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

    <div class="container">

        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header fa-align-center">@ViewBag.TitlePage</h3>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">

                    @using (Html.BeginForm("geraExcel1", "FinancingReport", FormMethod.Post))
                    {
                    <div class="form-group">

                        <div class="col-md-1">
                            @Html.Label("De")
                        </div>

                        <div class="col-md-3">
                            <input type="date" name="" id="">
                        </div>

                        <div class="col-md-1">
                            @Html.Label("Até")
                        </div>
                        <div class="col-md-3">
                            <input type="date" name="" id="">
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="well well-sm col-md-10">
                <div class="form-group">
                    <div class="radio">
                        <label class="btn btn-default">
                            @Html.RadioButton("gender", "Male", true, new { id = "IsMale", name="status",
                            value="Todos"
                            })
                            Todos
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <div class="radio">
                        <label class="btn btn-default">
                            @Html.RadioButton("gender", "Female", new { id = "IsFemale", name = "status", value =
                            "Ativo" })
                            Ativo
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <div class="radio">
                        <label class="btn btn-default">
                            @Html.RadioButton("gender", "Female", new { id = "IsFemale", name = "status", value =
                            "Inativo" })
                            Inativo
                        </label>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="form-group">
                    <div class="input-group-btn">
                        <input type="submit" value="Gerar Relatório" class="btn btn-primary" />
                    </div>
                </div>
            </div>
        </div>

    </div>

Browser other questions tagged

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