Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Label Align Right Using Bootstrap 4 Modal

How can I make this label align right? I can only align it left. I have to override the bootstrap 4 default value of justify-content: center to justify-content: right !important; But it aligns to the left. How can I align it to the right?

<div class="modal-body">
    <form class="form-horizontal">
        <div class="form-inline">
            <label class="col-md-4">Type</label>
            <input class="col-md-8" type="email" class="form-control">
        </div>
    </form>
</div>

CSS:

div.form-inline label.col-md-4 {
    justify-content: right !important; 
}

enter image description here

like image 956
Joseph Avatar asked Sep 21 '17 08:09

Joseph


People also ask

How do I align a label to the right in Bootstrap?

Use the . form-horizontal class in Bootstrap to align labels and groups of form controls in a horizontal layout.

How do I right align a label in CSS?

Solutions with CSS properties We specify the margin-bottom of our <div> element. Then, we set the display of the <label> element to "inline-block" and give a fixed width. After that, set the text-align property to "right", and the labels will be aligned with the inputs on the right side.

How do I right align text in a label?

Align the text left or right Select the text that you want to align. On the Home tab, in the Paragraph group, click Align Left or Align Right .


2 Answers

add class "text-right" to label

<div class="modal-body">
    <form class="form-horizontal">
        <div class="form-inline">
            <label class="col-md-4 text-right">Type</label>
            <input class="col-md-8" type="email" class="form-control">
        </div>
    </form>
</div>
like image 129
Нурлан Мендигалиев Avatar answered Nov 08 '22 10:11

Нурлан Мендигалиев


You need to change it to:

div.form-inline label.col-md-4{
    justify-content: flex-end;
}

justify-content: right is not a valid value.

like image 43
Florin Pop Avatar answered Nov 08 '22 12:11

Florin Pop