国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

Bootstrap對話框使用實例講解

2024-05-06 16:32:06
字體:
來源:轉載
供稿:網友

使用模態框的彈窗組件需要三層 div 容器元素

分別為 modal(模態聲明層) dialog(窗口聲明層) content(內容層)

在內容層里面,還有三層,分別為 header(頭部)、 body(主體)、 footer(注腳) 

一個簡單的對話框登陸/注冊例子

 

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Document</title>  <link rel="stylesheet" href="./css/bootstrap.min.css">  <script src="./js/jquery.min.js"></script>  <script src="./js/bootstrap.min.js"></script>  <style>    .modal-dialog {      width: 20%;    }    .modal-footer, .modal-header {      text-align: center;    }    input {      width: 80%;    }  </style></head><body>  <!-- LOGIN MODULE -->  <div id="loginModal" class="modal fade" tabindex="-1">    <div class="modal-dialog">      <div class="modal-content">        <div class="modal-header">          <button type="button" class="close" data-dismiss="modal">            <span>×</span>          </button>          <h4 class="modal-title">會員登錄</h4>        </div>        <div class="modal-body">          <label for="log_uname">            <span>帳號:</span>            <input id="log_uname" name="log_uname" type="text" placeholder="input your account">          </label>          <br>          <label for="log_passwd">            <span>密碼:</span>            <input id="log_passwd" name="log_passwd" type="password" placeholder="input your password">          </label>        </div>        <div class="modal-footer">          <button type="button" class="btn btn-primary">登錄</button>          <button type="button" class="btn btn-warning" data-dismiss="modal">退出</button>        </div>      </div>    </div>  </div>  <!-- LOGIN MODULE -->  <div id="registerModal" class="modal fade" tabindex="-1">    <div class="modal-dialog">      <div class="modal-content">        <div class="modal-header">          <button type="button" class="close" data-dismiss="modal">            <span>×</span>          </button>          <h4 class="modal-title">注冊會員</h4>        </div>        <div class="modal-body">          <label for="uname">            <span>帳號:</span>            <input id="reg_uname" name="reg_uname" type="text" placeholder="input your account">          </label>          <br>          <label for="reg_passwd">            <span>密碼:</span>            <input id="reg_passwd" name="reg_passwd" type="password" placeholder="input your password">          </label>          <label for="reg_confirm_passwd">            <span>確認:</span>            <input id="reg_confirm_passwd" name="reg_confirm_passwd" type="password" placeholder="confirm your password">          </label>        </div>        <div class="modal-footer">          <button type="button" class="btn btn-primary">注冊</button>          <button type="button" class="btn btn-warning" data-dismiss="modal">退出</button>        </div>      </div>    </div>  </div>  <button class="btn btn-primary" data-toggle="modal" data-target="#loginModal">登陸</button>  <button class="btn btn-warning" data-toggle="modal" data-target="#registerModal">注冊</button></body></html>

對話框其他知識

jQuery方式聲明對話框

$('#myModal').modal({  show : true,  backdrop : false,  keyboard : false,  remote : 'index.html',});

jQuery方式顯示對話框

$('#myBtn').on('click', function () {  $('#myModal').modal('show');});

對話框的事件

show.bs.modal  ==> 在show方法調用時立即觸發

shown.bs.modal  ==> 在模態框完全顯示出來并且CSS動畫完成之后觸發

hide.bs.modal ==> 在hide方法調用時 還未關閉隱藏時觸發

hidden.bs.modal ==> 在模態框完全隱藏之后并且CSS動畫完成之后觸發

$('#myModal').on('show.bs.modal', function () {  alert('show !');});

邊緣彈出框

<button class="btn btn-lg btn-danger" type="button" data-toggle="popover"  $('button').popover();</script>

其他方法

$('button').popover('show'); //顯示$('button').popover('hide'); //隱藏$('button').popover('toggle'); //反轉顯示和隱藏$('button').popover('destroy'); //隱藏并銷毀

事件

show.bs.popover ==> 在調用show方法時觸發

shown.bs.popover ==> 在顯示整個彈窗時觸發

hide.bs.popover ===> 在調用hide方法時觸發

hidden.bs.popover ==> 在完全關閉整個彈出時觸發

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 甘洛县| 略阳县| 闽清县| 江永县| 孙吴县| 青铜峡市| 安顺市| 黎平县| 花垣县| 景泰县| 余干县| 新龙县| 惠来县| 苍溪县| 永州市| 乌恰县| 松潘县| 辽宁省| 宁武县| 临泽县| 雅江县| 汪清县| 阿坝| 始兴县| 盱眙县| 石首市| 古交市| 济宁市| 乐山市| 章丘市| 大同县| 托克逊县| 大兴区| 容城县| 德保县| 赤城县| 手游| 巩留县| 顺昌县| 桂阳县| 湖口县|