I have the following markup.
<div class="row">
<div class="col-md-6">
<h4>Title</h4>
</div>
<div class="col-md-6 form-inline">
<div class="form-group">
<label for="TrackId">Track:</label>
<select class="form-control mb-2 mx-sm-4" data-val="true" data-val-required="The Track: field is required." id="TrackId" name="TrackId">
<option selected="selected" value="1">Track A</option>
<option value="2">Track B</option>
<option value="3">Track C aslkdfjaksdfjlskjdflaksdjfklasjdlksdjf</option>
</select>
</div>
</div>
</div>
And it looks something like this:
How can I right-align my <label>
and <select>
elements within the container <div>
?
4
Answers
You can use Bootstrap’s utility classes
d-flex
andalign-items-center
in this case. See the snippet below:If you convert these utility classes into CSS then it just means:
Adding
ml-auto
to yourform-group
div should do the trickyou could use the
.justify-content-between
class together with the.row
class.and the flex does the rest.
Code should be like this,
.justify-content-between this is build in class from BS5. Hope simply this will be worked, lets try it.