Vertically center Bootstrap 4 custom checkbox

0

I'm working with Bootstrap 4.0 and I'm trying to put together a form-row that has two columns, on the left a input and on the right a custom-control-input of type checkbox .

My problem is that I can not vertically center the elements of the right column, looking in the documentation of the forms makes use of the class align-items-center along with form-row , but apparently, it only applies using form-group , not with input-group

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<form>

    <div class="form-row">

            <div class="col-6">
                <label class="col-form-label col-form-label-sm" for="ruedas">Ruedas</label>
                <div class="input-group input-group-sm ">
                    <input type="text" id="ruedas" class="form-control">
                    <div class="invalid-feedback">Error de validación proporcionado por el backend</div>
                </div>
            </div>

            <div class="col-6">
                <div class="custom-control custom-checkbox mt-3">
                    <input type="checkbox" class="custom-control-input" id="tieneRuedasAisladas">
                    <label class="custom-control-label" for="tieneRuedasAisladas">¿Tiene Ruedas Aisladas?</label>
                </div>
            </div>        
    </div>

</form>

Is there a Bootstrap method to solve this? I tried to play with the margin classes m-* , but I could not reach a result that was accurate enough

Thanks for the time!

    
asked by Juan Salvador Portugal 12.09.2018 в 14:22
source

1 answer

0

Add the following lines to your css code:

.col-6 {
  position: relative;
}
.mt-3 {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
    
answered by 12.09.2018 / 14:34
source