This question already has answers here:
Vertical Align Center in Bootstrap 4 [duplicate]
(20 answers)
Closed 4 years ago.
I created a structure composed by two columns, the first have three radio buttons which I need to align to center (vertically), and the second contains some input field.
The structure have the following configuration:
<div class="row">
<div class="col-xs-12 col-sm-6">
<div class="mt-3 content-checkbox">
<div class="custom-control custom-radio">
<input type="radio" id="foo" name="test" checked class="custom-control-input">
<label class="custom-control-label" for="foo">Foo</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" id="foo1" name="test" class="custom-control-input">
<label class="custom-control-label" for="foo1">Foo</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" id="foo2" name="test" class="custom-control-input">
<label class="custom-control-label" for="foo2">Test</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6">
<div class="mt-3 text-center">
<div class="form-group">
<div class="form-group">
<label>Foo1</label>
<input type="text" class="form-control date" id="birthdatepicker" data-toggle="date-picker" data-single-date-picker="true">
</div>
<div class="form-group">
<label>Foo2</label>
<input type="text" class="form-control date" id="daterangetime" data-toggle="date-picker" data-time-picker="true" data-locale="{'format': 'DD/MM hh:mm A'}">
</div>
</div>
</div>
</div>
</div>
as you can see the result is this:
enter image description here
how can I align the radio button to the center vertically?
This is a JSFIDDLE.
You can add the following classes to the column (The one with the radio buttons.) and it would work:
d-flex align-items-center justify-content-center
You can find more information regarding these classes and more flex options here. This way you can even find more customizations that can help you even further.
Related
I'm using TwitterBootstrapMVC. To generate checkbox from enum, I'm using the below code
#form.FormGroup().CustomControls(Html.Bootstrap().CheckBoxesFromEnum($"{nameof(CSViewModel.Option)}"))
.CustomLabel("Options")
It gets rendered in HTML like this
<div class=" form-group">
<label class="control-label col-sm-1 col-md-1" for="">Options<span class="required" style="visibility:hidden;" wfd-invisible="true">*</span> </label>
<div class="col-xs-11 col-sm-11 col-md-11">
<div class="input-list-container">
<div class="checkbox">
<label for="Option_0">
<input id="Option_0" name="Option" type="checkbox" value="UpdateAsOfDate">UpdateAsOfDate<span class="required" style="visibility:hidden;">*</span>
</label>
</div>
</div>
</div>
</div>
Problem is, when I click on the checkbox, it won't show the checkmark. The label for is not getting linked with the checkbox input.
I tried editing the HTML in the browser by placing the "label for" after the input checkbox, and it works.
<div class=" form-group">
<label class="control-label col-sm-1 col-md-1" for="">Options<span class="required" style="visibility:hidden;" wfd-invisible="true">*</span> </label>
<div class="col-xs-11 col-sm-11 col-md-11">
<div class="input-list-container">
<div class="checkbox">
<input id="Option_0" name="Option" type="checkbox" value="UpdateAsOfDate">
<label for="Option_0">
UpdateAsOfDate
<span class="required" style="visibility:hidden;">*</span>
</label>
</div>
</div>
</div>
</div>
How to make the bootstrap to render the HTML like above ? Or how it can be fixed in bootstrap ?
I am trying to align my bootstrap check boxes horizontally using:
<div class="blueBorder container-fluid col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="row">
<div class="container-fluid">
<label class="text-left col-lg-12 col-md-12 col-sm-12 col-xs-12 col-form-label">Attributes:</label>
<input type="checkbox" value="">
<label class="checkbox-inline col-lg-2">Camp Site</label>
<input type="checkbox" value="">
<label class="checkbox-inline">Offsite Visit</label>
<input type="checkbox" value="">
<label class="checkbox-inline">Scout Den</label>
<input type="checkbox" value="">
<label class="checkbox-inline">Hike</label>
</div>
</div>
</div>
I had an issue with my input fields not filling the width of the bootstrap container and found the solution on stackoverflow to add the css:
input, textarea {
width: 100% !important
}
However, this is causing issues with the check box formatting.
With the css:
Without the css:
please use this source if working with bootstrap
https://getbootstrap.com/docs/4.0/components/forms/#default-stacked
I have Bootrap 4 text input like this
<div class="col-2 form-group">
<label for="follow">Följande</label>
<input type="text" class="form-control" id="follow" name="Follow" placeholder="" value="" required>
<div class="invalid-feedback">
Vänligen fyll i Följande.
</div>
</div>
And I want the checkbox label same vertical level as the text input and the check same vertical level and size as the text input. I have tried to swap the input and label code but nothing is working.
Checkbox code with custom checkbox.
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1">Check</label>
</div>
I have it like this
But want it like this
You should wrap your boxes properly within a container
<div class="container">
<div class="row">
<div class="col-sm-4 form-group">
<label for="follow">Följande</label>
<input type="text" class="form-control" id="follow" name="Follow" placeholder="" value="" required>
<div class="invalid-feedback">
Vänligen fyll i Följande.
</div>
</div>
<div class="col-sm-4 form-group">
<label for="follow">Check</label>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1"></label>
</div>
</div>
</div>
</div>
I tried to give the same width to these divs:enter image description here
<div class="form-group">
<span class="control-label own">Ownership?</span>
<div class="form-row">
<div class="col radio radio-inline borders-check col-md-6">
<input type="radio" id="ownyes" name="ownership" value="ownershipYes" checked>
<label class="vert checkbox-checked" for="ownyes">Yes</label>
</div>
<div class="col radio radio-inline borders-check col-md-6">
<input type="radio" id="ownno" name="ownership" value="ownershipNo">
<label class="vert checkbox-checked" for="ownno">No</label>
</div>
</div>
</div>
but I received this:
As you can see the second div goes down. What I must do?
I'm using bootstrap now for my design, earlier I used table, tr and td and it worked fine. But now, the design gets changed and I want to see both elements in a single row.
Here is my code
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<div class="radio">
<label><input type="radio" name="optradio">Option 1</label>
</div>
<input type="text" class="form-control" />
</div>
</div>
</div>
jsfiddle is here
https://jsfiddle.net/Z4ntn/438/
On top of it I would like to build similar kind in another rows.
Plz let me know what went wrong and what needs to be updated to see both in a single row.
Bootstrap says form-inline for elements in same line
like this
<div class="row">
<div class="col-xs-6">
<div class="form-inline">
<div class="radio">
<label><input type="radio" name="optradio">Option 1</label>
</div>
<input type="text" class="form-control"/>
</div>
</div>
</div>
EDIT
Bootply:
Form-inline