When using Bootstrap, is it better to place separate input fields inside their own col
or share a col
to keep them together and right-justified?
I have a combo and input that I want to display on the same row at the right-hand side of the screen. If I put them together in a col-4
, they are stacked on top of each other.
If I place them in their own col-2
elements, then only the second one is right-justified and the other one is centered.
I also tried adding style="display: inline"
to the input field, but it had no effect. What is the correct approach in this scenario?
It appears that select elements will occupy all available space. In the first case, if I used a larger number of columns (e.g. col-8
), all the space would be taken up by the first select element, without sharing it with the text input field.
Update:
Cervus' solution seems to work, except I need to keep ms-auto
or the first column will expand to take up the entire space. Here's my code:
If I remove col-auto
, the first column becomes too wide.