本文摘自PHP中文网,作者藏色散人,侵删。
bootstrap model隐藏的方法:首先外引boostrap和Jquery的文件环境;然后添加一个大的div;最后通过设置“aria-hidden”属性隐藏模态框即可。
![](http://ypimg.muzhuangnet.com/Collect/csharp/upload/article/000/000/020/5fb5e8d95217a691.jpg)
本教程操作环境:windows7系统、bootstrap3版,该方法适用于所有品牌电脑。
推荐:《bootstrap视频教程》
关于boostrap的modal隐藏问题(前端框架)
Modal(模态框)
首先,外引boostrap和Jquery的文件环境:
1 2 3 | <link rel= "stylesheet" href= "https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" >
<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>
|
一般是按钮或者链接触发modal
1 | <button class = "btn btn-primary btn-lg" data-toggle= "modal" data-target= "#myModal" >开始演示模态框</button><!-- 模态框(Modal) -->
|
首先添加一个大的div, fade:淡入淡出的效果 aria-hidden是为了隐藏模态框
1 | <div class = "modal fade" id= "myModal" tabindex= "-1" role= "dialog" aria-labelledby= "myModalLabel" aria-hidden= "true" )
|
然后在modal-content下,插入modal-header,modal-body,modal-footer
1 2 3 4 5 6 7 8 9 10 11 | <div class = "modal-content" >
<div class = "modal-header" >
<button type= "button" class = "close" data-dismiss= "modal" aria-hidden= "true" >×</button>
<h4 class = "modal-title" id= "myModalLabel" >模态框(Modal)标题</h4>
</div>
<div class = "modal-body" >在这里添加一些文本</div>
<div class = "modal-footer" >
<button type= "button" class = "btn btn-default" data-dismiss= "modal" >关闭</button>
<button type= "button" class = "btn btn-primary" >提交更改</button>
</div>
</div><!-- /.modal-content -->
|
×就是X的符号,点击关闭或者x或者点“Ese”都可以退出模态框
如果,你想点击提交更改也可以退出模态框,你可以添加一个onclick事件,在script里添加$("#myModal").modal("hide");如下
1 | <button type= "button" class = "btn btn-primary" onclick= "user_del()" id= "user-change" >提交更改</button>
|
1 2 3 | function user_del(){
$( "#user" ).modal( 'hide' );
}
|
以上就是退出功能问题,至于弹出的模态框,可以在modal-body里写入一系列的form-group,输入框组,详情进入boostrap的官网查看输入框组的学习即可,代码效果如下:
![](http://ypimg.muzhuangnet.com/Collect/csharp/upload/article/000/000/020/6723ad486837d32a311757d43340139c-0.png)
以上就是关于bootstrap model隐藏问题的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
简述为什么要使用bootstrap,有什么优点
用bootstrap做的网站有哪些
bootstrap less是什么
bootstrap分页怎么实现的
详解bootstrap中的辅助类
bootstrap怎么快速入门
有必要学bootstrap吗
bootstrap置信区间如何求
bootstrap请求javascript失败是怎么回事
bootstrap如何拖拽组件
更多相关阅读请进入《bootstrap》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » 关于bootstrap model隐藏问题