2017-03-20 7 views
0

私はモーダルヘッダー内にオーバーレイポップオーバーを追加しようとしていました。ポップオーバーが表示されたとき、ポップオーバーは元の位置を無視します。ブートストラップ - モーダルヘッダー内のオーバーレイポップオーバー

HTML

<div id="myModal" class="modal hide fade"> 
<div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal" 
     aria-hidden="true">&times;</button> 
    <div class="pull-right"> 
     <div class="overlay"> 
      <a class="btn" 
       rel="popover" 
       href="#" 
       name="link-menu" 
       data-content="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. " 
       data-original-title="A Title" 
       data-placement="bottom"> 
        popover menu 
      </a> 
     </div> 
    </div> 
    <h3>What is Lorem Ipsum?</h3> 
</div> 
<div class="modal-body"> 
    <p>  
      Lorem Ipsum is simply dummy text of the printing and typesetting          industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
    </p> 
</div> 
<div class="modal-footer"> 
    <a href="#" class="btn">Close</a> 
    <a href="#" class="btn btn-primary">Save changes</a> 
</div> 

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a> 

CSS

.overlay { 
    position: relative; 
    background-color: rgba(0, 0, 0, 0); 
} 

.overlay.on { 
    position: fixed; 
    top: 0; 
    left: 0; 
    height: 100%; 
    width: 100%; 
    background-color: rgba(0, 0, 0, 0.5); 
    z-index: 10; 
} 

は、ここで私は達成することができたもののフィドルです。 http://jsfiddle.net/rjrimorin/p6BAD/50/

大変助かりました!ありがとうございました!

答えて

1

Updated FIDDLE

オーバーレイクラスからposition: relativeを削除し、.overlay.on

$('a[rel=popover]').popover(); 

    $("a[name='link-menu']").click(function() { 
    $("div.overlay").toggleClass("on"); 
    }); 
.btn{ 
    margin-right: 5px; 
} 

.overlay { 
position: relative; 
    background-color: rgba(0, 0, 0, 0); 
} 
.overlay.on { 
    position: static; 
    top: 0; 
    left: 0; 
    height: 100%; 
    width: 100%; 

    z-index: 10; 
} 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
<div id="myModal" class="modal hide fade"> 
    <div class="modal-header"> 
     <button type="button" class="close" data-dismiss="modal" 
      aria-hidden="true">&times;</button> 
     <div class="pull-right"> 
      <div class="overlay"> 
       <a class="btn" 
        rel="popover" 
        href="#" 
        name="link-menu" 
        data-content="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. " 
        data-original-title="A Title" 
        data-placement="bottom"> 
         popover menu 
       </a> 
      </div> 
     </div> 
     <h3>What is Lorem Ipsum?</h3> 
    </div> 
    <div class="modal-body"> 
     <p>  
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
     </p> 
    </div> 
    <div class="modal-footer"> 
     <a href="#" class="btn">Close</a> 
     <a href="#" class="btn btn-primary">Save changes</a> 
    </div> 
</div> 

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a> 
+0

こんにちはNeophyte、答えはありがたいですが、私はオーバーレイが必要なので、ポップオーバーが表示されたときにはポップオーバーにのみ焦点を当て、モーダルは解除不可能になるようにします。 – monsieuroman

0

ためposition: staticposition: fixedを変更するには、このことがある:

.btn{ 
    margin-right: 5px; 
} 

.overlay { 
    position: relative; 
    background-color: rgba(0, 0, 0, 0); 
} 
.overlay.on { 
    position: fixed; 
    top: 0; 
    left: 0; 
    height: 100%; 
    width: 100%; 
    background-color: rgba(0, 0, 0, 0.5); 
    z-index: 10; 
} 

.overlay.on { 
    position: relative; 
    background-color: transparent; 
} 
.popover.fade.bottom.in { 
    width: 250px; 
    left: -50% !important; 
} 
+0

こんにちはrinatoptimus、答えのおかげで、オーバーレイがなくなった、私はユーザーがポップオーバーにのみ焦点を当てることができ、モーダルはunclickableとなるようにオーバーレイが必要です。 – monsieuroman

+0

これはhttp://jsfiddle.net/rinatoptimus/04hebpjs/です – rinatoptimus

関連する問題