一、模態(tài)框(Modal)是覆蓋在父窗體上的子窗體。通常,目的是顯示來自一個(gè)單獨(dú)的源的內(nèi)容,可以在不離開父窗體的情況下有一些互動(dòng)。子窗體可提供信息、交互等。
二、如果想要單獨(dú)引用該插件的功能,那么您需要引用 modal.js?;蛘呖梢砸?nbsp;bootstrap.js 或壓縮版的 bootstrap.min.js
引入之后直接上代碼示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Bootstrap 實(shí)例 - 模態(tài)框(Modal)插件</title> <link rel="stylesheet" rel="external nofollow" > <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <h3>創(chuàng)建模態(tài)框(Modal)</h3> <!-- 按鈕觸發(fā)模態(tài)框: class="btn btn-primary btn-lg":是指定class為"按鈕的加大primary"樣式 data-toggle="modal":應(yīng)該是模態(tài)框的固定寫法,只能為modal,至少自己試驗(yàn)發(fā)現(xiàn)是這樣的 data-target="#myModal":通過選擇器指向 id="myModal" 的元素,也就是要顯示和隱藏的模態(tài)框目標(biāo) --> <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> 開始演示模態(tài)框 </button> <!-- 模態(tài)框(Modal) --> <!-- class="modal fade": modal——用來把div識(shí)別成模態(tài)框 fade——當(dāng)模態(tài)框被切換時(shí),內(nèi)容會(huì)淡入淡出 id="myModal":就是被指定為上面說的data-target屬性選擇的元素 tabindex:屬性規(guī)定元素的 tab 鍵控制次序 aria-labelledby="myModalLabel":引用模態(tài)框的標(biāo)題(去掉影響不大) aria-hidden:="true":設(shè)置模態(tài)框不可見,等到點(diǎn)擊按鈕之后顯示 --> <div class="modal fade" id="myModal" tabindex="1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <!-- data-dismiss="modal":加上這個(gè),使得點(diǎn)擊該button時(shí)會(huì)關(guān)閉模態(tài)框,下面的關(guān)閉按鈕也是一樣加了這個(gè)屬性 --> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button> <h5 class="modal-title" id="myModalLabel"> 模態(tài)框(Modal)標(biāo)題 </h5> </div> <div class="modal-body"> <input type="text" placeholder="輸入......"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button> <button type="button" class="btn btn-primary">提交更改</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal --> </div> </body> </html>
文章名稱:Bootstrap實(shí)現(xiàn)模態(tài)框效果-創(chuàng)新互聯(lián)
本文網(wǎng)址:http://chinadenli.net/article30/djghso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、定制開發(fā)、面包屑導(dǎo)航、企業(yè)建站、定制網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容