您好,登錄后才能下訂單哦!
可以切換模態(tài)框(Modal)插件的隱藏內(nèi)容:
1、通過(guò) data 屬性:在控制器元素(比如按鈕或者鏈接)上設(shè)置屬性 data-toggle="modal",同時(shí)設(shè)置 data-target="#identifier" 或 href="#identifier" rel="external nofollow" 來(lái)指定要切換的特定的模態(tài)框(帶有 id="identifier")
2、通過(guò) JavaScript:使用這種技術(shù),您可以通過(guò)簡(jiǎn)單的一行 JavaScript 來(lái)調(diào)用帶有 id="identifier" 的模態(tài)框:
$('#identifier').modal(options)
代碼:
<!DOCTYPE html> <html> <head> <title>Bootstrap-模態(tài)框Modal</title> <meta charset="utf-8"> <link rel="stylesheet" href="css/bootstrap.min.css" rel="external nofollow" > </head> <body> <div class="container"> <h3>創(chuàng)建模態(tài)框(Modal)</h3> <!-- 按鈕觸發(fā)模態(tài)框 --> <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">開(kāi)始演示模態(tài)框</button> <!-- 模態(tài)框(Modal) --> <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"> <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"> 在這里添加一些文本 </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> <script src="js/jquery.min.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html>
注:
aria-labelledby="myModalLabel" aria-hidden="true"
官方API 意思是為盲人或者一些可讀設(shè)備設(shè)置的 role的設(shè)置告訴設(shè)備這是彈出框 aria-labelledby=".."里面是描述信息,然后aria-hidden="true"再把它隱藏掉,一般人用不到,這樣寫(xiě)比較規(guī)范
增強(qiáng)模態(tài)框的可訪問(wèn)性
務(wù)必為 .modal 添加 role="dialog" 和 aria-labelledby="..." 屬性,用于指向模態(tài)框的標(biāo)題欄;為 .modal-dialog 添加 aria-hidden="true" 屬性。
另外,你還應(yīng)該通過(guò) aria-describedby 屬性為模態(tài)框 .modal 添加描述性信息。
效果圖
參考地址:http://www.w3cschool.cn/bootstrap/bootstrap-modal-plugin.html
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。