<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <link href="css/bootstrap.min.css" rel="stylesheet" /> <link rel="stylesheet" href="css/font-awesome.min.css" /> <style> li { list-style: none; } .modal-li li { height: 45px; line-height: 45px; } .text-input { display: inline-block; width: 80%; margin-left: 10px; } </style> </head> <body> <!--主页面数据 start--> <div style="margin:50px;"> <table class="table table-bordered"> <thead> <tr> <th>姓名</th> <th>编号</th> <th>性别</th> <th>修改</th> </tr> </thead> <tbody> <tr> <td>龙彻</td> <td>20160621</td> <td>男</td> <td style="color:#f00;cursor:pointer;" onclick="editInfo(this)">修改</td> </tr> <tr> <td>Sachin</td> <td>20160621111</td> <td>女</td> <td style="color:#f00;cursor:pointer;" onclick="editInfo(this)">修改</td> </tr> <tr> <td>Uma</td> <td>23341</td> <td>男</td> <td style="color:#f00;cursor:pointer;" onclick="editInfo(this)">修改</td> </tr> </tbody> </table> </div> <!--主页面数据 start--> <!--模态窗口 --> <div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div 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">×</span> </button> <h4 class="modal-title" id="myModalLabel">模态窗口</h4> </div> <div class="modal-body modal-li"> <form> <ul> <li> <label for="name">姓名</label> <input type="text" class="form-control text-input" id="name" placeholder="请输入姓名"> </li> <li> <label for="name">编号</label> <input type="text" class="form-control text-input" id="number" placeholder="请输入编号"> </li> <li> <label for="name">性别</label> <input type="radio" name="sex" id="man" value="男" style="margin-left:10px;"/>男 <input type="radio" name="sex" id="women" value="女" style="margin-left:10px;"/>女 </li> </ul> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button> <button type="button" class="btn btn-primary" onclick="update()">保存</button> </div> </div> </div> </div> <!--end-模态窗口 --> <script src='js/jquery-1.10.2.min.js'></script> <script src="js/bootstrap.min.js"></script> </body> </html>
s:
bootstrap框架中,使用模态框(modal)的弹窗组件需要三层 div 容器元素,分别为:
1. 外层:modal(模态声明层)。
2. 中间层:dialog(窗口声明层)。
3. 内层:content(内容层)。在内容层里面,还包含三层,分别为 header(头部)、body(主体)、footer(注脚)。
案例效果如下:
说明:案例中设置按钮的数据切换方式(data-toggle)是modal,数据目标(data-target)指向模态框的id(mod1)。
网页文件modal.html的代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>模态框插件</title>
<link rel="stylesheet" href="css/bootstrap.css">
<style type="text/css">
*{
margin:0px;
padding:0px;
}
body{
font-size:14px;
}
</style>
</head>
<body>
<!--tabindex="-1"表示关闭焦点,使得按esc键也可以关闭打开的对话框 -->
<div class="modal fade" id="mod1" tabindex="-1">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal"><span>×</span></button>
<h4 class="modal-title">用户登陆</h4>
</div>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon">用户名:</span>
<input type="text" class="form-control" placeholder="请输入用户名">
</div>
<p></p>
<div class="input-group">
<span class="input-group-addon">密 码:</span>
<input type="password" class="form-control" placeholder="请输入密码">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default">注册</button>
<button class="btn btn-primary">登陆</button>
</div>
</div>
</div>
</div>
<hr>
<button class="btn btn-primary" data-toggle="modal" data-target="#mod1">用户登陆</button>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
至此,案例制作完成。
为美工详情页增加模态框效果,可以采用以下步骤和技巧:
通过以上步骤和技巧,你可以成功为美工详情页设计增加模态框效果。模态框可以提供一种交互式和聚焦式的用户体验,增加页面的互动性和吸引力。
*请认真填写需求信息,我们会在24小时内与您取得联系。