![](/img/trans.png)
[英]i want to call javascript pop up on Linkbutton but it post back the page and pop up is disappeared
[英]i want javascript pop up in the center of page
我正在 Html 網站上工作,我有彈出代碼,但它顯示在頁面頂部,但我想在頁面中央顯示淡入淡出效果,請幫助我如何執行此操作。 謝謝
<script>function openModal(){
$("#exampleModalLong").modal();
setTimeout(function(){ $("#exampleModalLong").modal("hide"); }, 3000);
}</script>
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<center> <h1 class="modal-title" id="exampleModalLongTitle">The Janwari Group Of Companies</h1></center>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<center><h4>Description</h4></center>
</div>
</div>
</div>
</div>
編輯:更新為 jQuery 的淡入/淡出,因為我在 OP 中錯過了它。
您可以使用position:absolute將模態居中。 請參閱此類似帖子並相應地更改您的 CSS。
使用 jQuery 在模式上淡入/淡出並以 CSS 為中心的示例
.modal { width: 300px; height: 300px; position: absolute; left: 50%; top: 50%; margin-left: -150px; margin-top: -150px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function() { $(".close").click(function() { $(".modal").fadeOut(3000); }); $(".open").click(function() { $(".modal").fadeIn(3000); }); }); </script> <button type="button" class="open" data-dismiss="modal" aria-label="Open">Open </button> <div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <center> <h1 class="modal-title" id="exampleModalLongTitle">The Janwari Group Of Companies</h1> </center> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <center> <h4>Description</h4> </center> </div> </div> </div> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.