2017-05-19 5 views
0

私は長いフルスクリーンポップアップモーダル(親モーダル)を持っています。このモーダル(親モーダル)の内部には、別のポップアップモーダル(子モーダル)があります。 「親モダル」をスクロールしてから「子モダル」を開くと、「子モダル」のモーダルは垂直方向に中央に配置されません。長いポップアップモーダルの中でポップアップモーダルを縦にセンタリングする方法

+0

コードを追加したり、いじるしてください!ありがとう。 –

+0

https://jsfiddle.net/jasny/ZcLSE/ – sairaj

答えて

1

希望は、これはあなたに役に立つかもしれません!

.modal { 
 
} 
 
.vertical-alignment-helper { 
 
    display:table; 
 
    height: 100%; 
 
    width: 100%; 
 
} 
 
.vertical-align-center { 
 
    /* To center vertically */ 
 
    display: table-cell; 
 
    vertical-align: middle; 
 
} 
 
.modal-content { 
 
    /* Bootstrap sets the size of the modal in the modal-dialog class, we need to inherit it */ 
 
    width:inherit; 
 
    height:inherit; 
 
    /* To center horizontally */ 
 
    margin: 0 auto; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<!-- Latest compiled and minified CSS --> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 

 
<!-- Optional theme --> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 
 

 
<!-- Latest compiled and minified JavaScript --> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 
<!-- Button trigger modal --> 
 
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Launch demo modal</button> 
 
<!-- Modal --> 
 
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
 
    <div class="vertical-alignment-helper"> 
 
     <div class="modal-dialog vertical-align-center"> 
 
      <div class="modal-content"> 
 
       <div class="modal-header"> 
 
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span> 
 

 
        </button> 
 
        <h4 class="modal-title" id="myModalLabel">Modal title</h4> 
 

 
       </div> 
 
       <div class="modal-body">...</div> 
 
       <div class="modal-footer"> 
 
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
 
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1">Save changes</button> 
 
       </div> 
 
      </div> 
 
     </div> 
 
    </div> 
 
</div> 
 
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
 
    <div class="vertical-alignment-helper"> 
 
     <div class="modal-dialog vertical-align-center"> 
 
      <div class="modal-content"> 
 
       <div class="modal-header"> 
 
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span> 
 

 
        </button> 
 
        <h4 class="modal-title" id="myModalLabel">Modal title</h4> 
 

 
       </div> 
 
       <div class="modal-body">...</div> 
 
       <div class="modal-footer"> 
 
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
 
        <button type="button" class="btn btn-primary">Save changes</button> 
 
       </div> 
 
      </div> 
 
     </div> 
 
    </div> 
 
</div>

+0

はい!それはしました。ありがとう – sairaj

0

は子モーダルでこのスタイルを試してみてください:

#parent-modal{ 
position:relative; 
} 
#child-modal{ 
    position:absolute; 
    top: 50%; 
    transform: translateY(-50%); 
    -webkit-transform: translateY(-50%); 
} 
+0

私はそのCSSを持っています。私はjsのフィドルでそれを追加しませんでした – sairaj

+0

それは垂直にポップアップを中心に変換プロパティを使用することは非常に良いです。それには多くの問題があります。とにかくお返事ありがとうございます – sairaj

関連する問題