bootstrap模拟弹出页面的demo

 时间:2026-02-20 20:21:12

1、引入bootstrap相应的js,以及jquery;使用外部引入;

<head>

<meta charset="utf-8"> 

<title>Bootstrap 实例弹出页面实例</title>

<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>

<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

bootstrap模拟弹出页面的demo

2、button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">

开始演示模态框

</button>

<div id="img"></div>

<!-- 模态框(Modal) -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

<div class="modal-dialog">

bootstrap模拟弹出页面的demo

3、<div class="modal-content">

<div class="modal-header">

<button id="modelClose" type="button" class="close" data-dismiss="modal" 

aria-hidden="true">×

</button>

<h4 class="modal-title" id="myModalLabel">

模态框(Modal)标题

</h4>

</div>

<div class="modal-body">

按下 ESC 按钮退出。

</div>

bootstrap模拟弹出页面的demo

4、<div class="modal-footer">

<button type="button" class="btn btn-default" 

data-dismiss="modal">关闭

</button>

<button id="model" type="button" class="btn btn-primary">

提交更改

</button>

</div>

</div>

</div>

</div>

bootstrap模拟弹出页面的demo

5、<script>

$(function(){

$('#model').click(function(){

$("#modelClose").click();

$("#img").append("<div style='height: 100px;width: 100px; background-color: #aaa;'><img src='img/timg.gif' style='height: 100px;width: 100px;'></div>")

})

})

</script>

bootstrap模拟弹出页面的demo

6、如果想要一个页面有两个弹窗,并且弹出不同的内容;

<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#2">

需要设置data-target ,这里可以把他理解成id;

<div class="modal fade" id="2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

和这个id属性一一对应,即可实现点击第二个弹出不同页面;

bootstrap模拟弹出页面的demo

7、记录方法,仅供参考;

bootstrap模拟弹出页面的demo

  • 用Mathematica画一个翻卷的莫比乌斯带
  • Axure RP8如何实现点击图片隐藏其中一部分
  • 谷歌浏览器如何设置显示“主页”按钮?
  • vs2017如何导入android项目
  • 矿用电机车工作过程你了解多少
  • 热门搜索
    石家庄工商职业学院怎么样 空调如何拆装 如何做贺卡 生活有点甜 从绘画开始的东京生活 嘴角起泡是什么原因 淘宝如何开网店 cf闪退怎么解决 如何解散qq群 怎么用q币发红包