2017-09-21 5 views
3

Wie kann ich dieses Etikett richtig ausrichten? Ich kann es nur nach links ausrichten. Ich muss den Bootstrap 4-Standardwert von justify-content: center zu überschreiben, aber es richtet sich nach links. Wie kann ich es nach rechts ausrichten?Etikett mit Bootstrap 4 richtig ausrichten Modal

<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

Antwort

2

Sie müssen es ändern:

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

justify-content: right ist kein gültiger Wert.

+0

Dank. Und wie kann ich das Etikett mit der Eingangsgruppe auf die Mitte ausrichten? – Joseph

+0

Ich bin nicht ganz sicher, ich verstehe, was du meinst ... –

+0

Ich habe ein Bild hochgeladen. Ich meine, wie kann ich den Raum auf dem "Typ und" Eingabeformular gleich machen, so sieht es richtig ausgerichtet. So sieht es sogar auf der linken und rechten Seite. – Joseph

0

Bootstrap 4 verschoben zu flex Layout eher als block. Sie müssen justify-content: flex-end für Ihren Fall verwenden.

$('#myModal').on('shown.bs.modal', function() { 
 
    $('#myInput').focus() 
 
})
div.form-inline label.col-md-4{ 
 
    justify-content: flex-end; 
 
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" 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.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!-- Button trigger modal --> 
 
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal"> 
 
    Launch demo modal 
 
</button> 
 

 
<!-- Modal --> 
 
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> 
 
    <div class="modal-dialog" role="document"> 
 
    <div class="modal-content"> 
 
     <div class="modal-header"> 
 
     <h5 class="modal-title" id="exampleModalLabel">Modal title</h5> 
 
     <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 
 
      <span aria-hidden="true">&times;</span> 
 
     </button> 
 
     </div> 
 
     <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> 
 
     <div class="modal-footer"> 
 
     <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> 
 
     <button type="button" class="btn btn-primary">Save changes</button> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

Verwandte Themen