模态框

代码段:

<!DOCTYPE html>  
<html> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
            <!-- 引入 Bootstrap -->  
        <script src="js/jquery/3.3.1/jquery.min.js"></script>  
        <link href="css/bootstrap/3.3.7/bootstrap.min.css" rel="stylesheet">  
        <script src="js/bootstrap/3.3.7/bootstrap.min.js"></script>   
        <script src="js/holder.min.js"></script>  
    </head> 
<body> 
<!--模态框-->
<div class="container">
       <h3 class="page-header">模态框</h3>
       <!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>
<!--若上面的button换成a链接<a href="#myModal" class="btn btn-primary btn-lg" data-toggle="modal" >Launch demo modal</a>-->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<!--.modal fade淡入-->
  <div class="modal-dialog modal-sm" role="document"><!--.modal-lg|sm对话框大小-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button><!--data-dismiss="modal"关闭modal 框-->
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary save">Save changes</button><!--.save点击该按钮后,探出警告框:登录成功,关闭警告框后同时关闭modal框,具体实现见下script-->
      </div>
    </div>
  </div>
</div>

</div>
<!--
模态框基本框架,用js实现模态框
<div class="container">
       <h3 class="page-header">模态框</h3>
<button class="btn btn-primary btn-lg smodal" >Launch demo modal
</button>


<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"></div>
            <div class="modal-body"></div>
            <div class="modal-footer"></div>
        </div>
    </div>
</div>
</div>
这段script写在body外面
<script>
//js开启modal
$('.smodal').click(function(){
    $('#myModal').modal('show');
})
//模态框出现之后改变body样式
$('#myModal').on('shown.bs.modal',function(e){
    $('body').css({'background':'#aaf'});
})
</script>
-->
    </body>
<script>
    $('.save').click(function(){
        alert('登录成功!');
        $('#myModal').modal('hide');
    })

    
</script>
</html>

实现效果:

模态框

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值