2016-12-02 9 views
0

私はpopupモーダルがあり、10秒後に表示されます。しかし、それはページの上部に表示されているので、フッターのページの一番下に表示する必要があります。ページの下部にポップアップモデルを表示する方法は?

どうすればいいですか?

は、ここに私のコードです:

// Get the modal 
 
    var modal = document.getElementById('myModal'); 
 
    // Get the button that opens the modal 
 
    var btn = document.getElementById("myBtn"); 
 
    // Get the <span> element that closes the modal 
 
    var span = document.getElementsByClassName("close2")[0]; 
 
    // When the user clicks the button, open the modal 
 
    btn.onclick = function() { 
 
     modal.style.display = "block"; 
 
    } 
 
    // When the user clicks on <span> (x), close the modal 
 
    span.onclick = function() { 
 
     modal.style.display = "none"; 
 
    } 
 
    // When the user clicks anywhere outside of the modal, close it 
 
    window.onclick = function(event) { 
 
     if (event.target == modal) { 
 
      modal.style.display = "none"; 
 
     } 
 
    }
.close { 
 
    color: white; 
 
    float: right; 
 
    font-size: 28px; 
 
    font-weight: bold; 
 
} 
 
.close:hover, 
 
.close:focus { 
 
    color: #000; 
 
    text-decoration: none; 
 
    cursor: pointer; 
 
} 
 
.modal-header { 
 
    padding: 2px 16px; 
 
    background-color: #2098d1; 
 
    color: white; 
 
} 
 
.modal-body { 
 
    padding: 2px 16px; 
 
} 
 
.modal-footer { 
 
    padding: 2px 16px; 
 
    background-color: #5cb85c; 
 
    color: white; 
 
} 
 
.modal { 
 
    position: absolute; 
 
    top: 200px; 
 
    right: 50px; 
 
    bottom: 0; 
 
    left: 0; 
 
    z-index: 1040; 
 
    overflow: auto; 
 
    overflow-y: auto; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 

 

 
<div class="modal fade" id="popup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
 
    <div class="modal-dialog"> 
 
     <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">Special Offer</h4> 
 
      </div> 
 
      <div class="modal-body"> 
 
       <h1 style="color:green">10% OFFER </h1> 
 
      </div> 
 
     </div> 
 
    </div> 
 
</div>

+0

モーダルに合わせてCSSを調整します。 – claudios

+0

あなたはCSSのplxを与えることができますか? – uiit

答えて

0

あなたはそんなにコードが必要な場合はわかりません。しかし、これは、このようにすることができます。

はJavaScript:

$(function() { 
    setTimeout(function() { 
    $("#popup").modal(); 
    }, 2000); 
}); 

CSS:

#popup { 
    top: auto; 
    bottom: 10px; 
    outline: none; 
} 

プレビュー

preview

Bootply:http://www.bootply.com/DmyamsX6qg
* リンクをクリックし、全画面表示を使用して機能をチェックしてください。

+0

レスポンスありがとうございます。私はあなたの 'css'コードを使用していますが、下に表示されています。[スクリーンショット](http://i66.tinypic.com/1568hvt.jpg)ですが、フッタの前のページ。 – uiit

関連する問題