2017-09-21 54 views
3

如何使此標籤對齊正確?我只能左對齊。我必須覆蓋引導程序4默認值justify-content: centerjustify-content: right !important;但它與左邊對齊。我怎樣才能將它對齊?使標籤對齊使用引導程序4模式

<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

回答

2

您需要將其更改爲:

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

justify-content: right不是有效的值。

+0

感謝。我如何使輸入組的標籤與中心對齊? – Joseph

+0

我不太確定我明白你的意思... –

+0

我上傳了一張照片。我的意思是我怎樣才能使空間在「類型」和「輸入表單」上都是一樣的,所以它看起來正確對齊。所以它看起來甚至在左側和右側。 – Joseph

0

引導程序4轉移到flex佈局而不是block。你必須使用justify-content: flex-end你的情況。

$('#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>