BootStrap对话框关闭按钮

点击关闭按钮使整个对话框关闭的属性是aria-hidden,将其值设置为true即可,例如:


<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>

下面是一个弹出对话框的示例:

其中css/bootstrap.min.css和js/bootstrap.min.js是BootStrap框架中自带的。可以去下载下来。


<!DOCTYPE html>
<!-- lang: html -->
<html>
<!-- lang: html -->
    <head>
<!-- lang: html -->
        <meta charset="utf-8">
<!-- lang: html -->
        <meta name="viewport" content="width=device-width,initial-sxale=1.0">
<!-- lang: html -->
        <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" media="screen">
<!-- lang: html -->
        <title>关闭按钮器作用的对话框</title>
<!-- lang: html -->
    </head>
<!-- lang: html -->
    <body>
<!-- lang: html -->
        <a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<!-- lang: html -->
        <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidder="true">
<!-- lang: html -->
            <div class="modal-header">
<!-- lang: html -->
                <button type="button" class="close" data-dismiss="modal" aria-hidder="true">x</button>
<!-- lang: html -->
                <h3>头部</h3>
<!-- lang: html -->
            </div>
<!-- lang: html -->
            <div class="modal-body">
<!-- lang: html -->
                <p>内容</p>
<!-- lang: html -->
            </div>
<!-- lang: html -->
            <div class="modal-footer">
<!-- lang: html -->
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
<!-- lang: html -->
                <button class="btn btn-primary">保存</button>
<!-- lang: html -->
            </div>
<!-- lang: html -->
        </div>
<!-- lang: html -->
        <script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<!-- lang: html -->
        <script type="text/javascript" src="../js/bootstrap.min.js"></script>
<!-- lang: html -->
    </body>
<!-- lang: html -->
</html>

你可能感兴趣的:(BootStrap对话框关闭按钮)