I have a form with several input fields formatted in this way with boostrap classes that work correctly.
<input class="form-control py-4" placeholder="Introduzca nombre completo del usuario" required name="name" type="text" id="name">
But if I try to apply these classes to a "select" tag it doesn't work right. Anything I select from the select is not displayed in the field. On the other hand, if py-4 is eliminated, the selected option is displayed correctly, although logically the field has a lower height than what was achieved with py-4.
<select class="form-control py-4" name="role_id" required>
<option value="" disabled selected>--Seleccionar rol--</option>
<option value="1">Administrador</option>
<option value="2">Autor</option>
<option value="3">Suscriptor</option>
</select>
Why isn't the py-4 class working fine in the select ?
ISSUE
The problem is that the classes you intend to use are mutually exclusive, i.e. the class
form-control
applies its own height value on the element:padding
If you also apply a not compatible ( ) rule to that element,py-4
the result is that the text in the container is not displayed correctly.SOLUTION
One possible solution is to apply your own rule for this particular case (if that's really what you intend to do with your element's container
select
).For example, you could add a class called
custom-auto-height
where you set the element's height toauto
, with the declaration!important
, so that it takes precedence over Bootstrap classes applied to the same element:and add it to your element
select
as the last class in the class chain (Cascading Styles):I hope this helps you solve the problem.