Home  >  Article  >  Web Front-end  >  Code implementation of dynamic modal box and static modal box in BootStrap

Code implementation of dynamic modal box and static modal box in BootStrap

不言
不言Original
2018-08-13 10:00:461951browse

The content this article brings to you is about the code implementation of dynamic modal boxes and static modal boxes in BootStrap. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

To use the bootStrap framework, you must overload its class, which means that the class must be the same.

The code is as follows:

Dynamic modal box

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.css">
    <script src="bootstrap-3.3.7/js/jquery.min.js"></script>
    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="bootstrap-3.3.7/js/docs.min.js"></script>

</head>
<body>
        <div>
                <div>
                    <div>bootstrap框架 <small>s</small>
                    </div>
                </div>
    <!-- 动态框 -->
<div>
    <!-- modal默认是隐藏的 -->
    <div>                  
        <div>
         <!-- 头部关闭按钮 -->
            <div>             
                <button type="button" class="close myclose" data-dismiss="modal"><span >&times</span></button>
                <div class="h3 modal-title">标题部分</div>
                <!-- 内容部分 -->
                <div>
                    <P>这是内容部分</P>
                </div>
                <!-- 页脚 -->
                <div>
                    <button type="button" class="btn btn-primary myclose" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-warning myclose">save</button>
                </div>
            </div>
        </div>
    </div>
    
</div>
    <a href="#" class="btn btn-success" id="show">显示对话框</a>
        </div>
</body>
</html>
<script>
    $(function(){
        $(&#39;#show&#39;).click(function(){
            $(&#39;.modal&#39;).modal(&#39;show&#39;)
        })
    })
</script>

Static modal box

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.css">
    <script src="bootstrap-3.3.7/js/jquery.min.js"></script>
    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="bootstrap-3.3.7/js/docs.min.js"></script>
</head>
<body>
    <div>
        <div>
            <div>bootstrap框架 <small>s</small>
            </div>
           
         <!-- 静态模态框 官方有一个bug就是在写静态框的时候在按钮上要绑定同一个class-->
                <div>
                    <div>
                        <div>
                            <button type="button" class="close myclose" data-dismiss="modal">
                                <span>&times;</span>
                            </button>
                            <h3>Model标题</h3>                            
                     </div>
                     <!-- body部分 -->
                     <div>
                         <p>这是身体部分</p>
                     </div>
                     <!-- footer部分 -->
                     <div>
                         <button class="btn btn-info myclose" data-dismiss="modal">close</button>
                         <button class="btn btn-primary myclose">save</button>
                     </div>
                    </div>
                </div>
           </div>
 </div> 
      </div>
    </div>
</body>
</html>
<script>
    $(function(){
        $(&#39;.myclose&#39;).click(function(){
            $(&#39;.modal-dialog&#39;).css(&#39;display&#39;,&#39;none&#39;)
        })
    })
</script>

Related recommendations:

How are tables in HTML created? (Code example)

Combining 2D and 3D in HTML and CSS3 to achieve animation effects

Various usages of select in html Summary (code)

The above is the detailed content of Code implementation of dynamic modal box and static modal box in BootStrap. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn