加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

为Bootstrap模态对话框添加拖拽移动功能

发布时间:2020-12-17 20:48:41 所属栏目:安全 来源:网络整理
导读:请自行下载使用到的Bootstrap库及jQuery库!DOCTYPE html html head lang= "en" meta charset= "UTF-8" title / title link href= "bootstrap.min.css" media= "screen" rel= "stylesheet" / head body !-- Button trigger modal -- button type= "button" cl
请自行下载使用到的Bootstrap库及jQuery库

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>

    <link href="bootstrap.min.css" media="screen" rel="stylesheet">

</head>
<body>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
    打开示例对话框
</button>

<!-- Modal -->
<div  class="modal fade"  id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div id="modalDialog" class="modal-dialog" role="document">
        <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>
                <h4 class="modal-title" id="myModalLabel">可拖动窗口</h4>
            </div>
            <div class="modal-body">
               按住左键开始拖动吧
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>


<script src="jquery-1.11.2.min.js"></script>
<script src="jquery-ui.min.js"></script><!--用户拖动元素,链接:http://api.jqueryui.com/draggable/#method-disable/-->
<script src="jquery.ui.touch-punch.min.js"></script><!--移动设备用户拖动元素,依赖juery-ui.min.js,链接:http://touchpunch.furf.com/-->

<script src="bootstrap.min.js"></script>

<script>
    $(document).ready(function(){

        $("#modalDialog").draggable();//为模态对话框添加拖拽
        $("#myModal").css("overflow","hidden");//禁止模态对话框的半透明背景滚动

    })
</script>

</body>
</html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读