Bootstrap 模态框(Modal)插件 模态框(Modal)是覆盖在父窗体上的子窗体。通常,目的是显示来自一个单独的源的内容,可以在不离开父窗体的情况下有一些互动。子窗体可提供信息、交互等。下面通过代码给大家介绍bootstrap 模态框插件,先给大家展示下效果图:
页面效果:
html+js:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>my love-用户登录</title> <link href="https://www.jb51.net/css/bootstrap.css"> <link href="https://www.jb51.net/css/login.css"> <link href="https://www.jb51.net/css/register.css"> <script src="https://www.jb51.net/js/jquery.js" type="text/javascript"></script> <script src="https://www.jb51.net/js/modal.js" type="text/javascript"></script> </head> <body> <div> <form action="index.html"> <div> <label>用户名:</label> <div> <input type="text" placeholder="请输入用户名......"> </div> </div> <div> <label>密 码:</label> <div> <input type="password" placeholder="请输入密码......"> </div> </div> <div> <div> <button type="button">登录</button> </div> <div> <!-- Button register-modal --> <button type="button" data-toggle="modal" data-target="#register-modal">注册</button> </div> </div> </form> <!-- Modal --> <div tabindex="-1" role="dialog" aria-labelledby="register-modal-label"> <div role="document"> <div> <div> <button type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4>新用户注册:</h4> </div> <div> <div> <div> <label>邮 箱:</label> <div> <input type="text"> </div> </div> <div> <label>用户名:</label> <div> <input type="text"> </div> </div> <div> <label>密 码:</label> <div> <input type="password"> </div> </div> <div> <label>确认密码:</label> <div> <input type="password"> </div> </div> </div> </div> <div> <button type="button">注册</button> <button type="button" data-dismiss="modal">返回</button> </div> </div> </div> </div> </div> <script type="text/javascript"> $(function() { $('.register-button').click(function() { document.location.href = "login.html"; }); }); </script> </body> </html>
login.css
body { background: url(../image/sun.jpg) no-repeat; -moz-background-size: 100% 100%; -webkit-background-size: 100% 100%; } .main { width: 365px; height: 200px; margin: 230px auto; /*border: 2px solid #3a9c08;*/ } .form-horizontal { padding-top: 30px } .main>.form-horizontal>.form-group>.col-xs-3.col-md-3.control-label.no-padding-right { color: #fff; } label.control-label.no-padding-right { padding-right: 0; font-size: 17px; } .form-horizontal .form-group { margin-right: 0; margin-left: 0; } .form-group.bottom-button { padding-top: 10px; }
register.css
.modal-dialog .modal-content .modal-header { background: url(../image/registerTop.png) no-repeat; -moz-background-size: 100% 100%; -webkit-background-size: 100% 100%; } .modal-dialog .modal-content .modal-footer { background-color: #d5feff; }
以上所述是小编给大家介绍的Bootstrap 模态框(Modal)插件代码解析,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章: