<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>host</title> <style> <!-- 隐藏设置--> .hide{ display: none; } <!-- 遮罩层样式--> .shade{ position: fixed; top:0; right: 0; left: 0; bottom: 0; background: black; opacity: 60%; z-index: 100; } <!-- 弹出层样式--> .add_modal{ position: fixed; height: 300px; 400px; top: 100px; left: 50%; z-index: 101; border: 1px solid red; background: white; margin-left: -200px; } </style> </head> <body> <h1>主机信息(对象)</h1> <div> <input id = "add_host" type="button" value="添加" /> </div> <table border="1"> <thead> <tr> <th>序号</th> <th>主机名</th> <th>IP</th> <th>端口</th> <th>业务线</th> </tr> </thead> <tbody> {% for row in v1 %} <tr hid="{{ row.nid }}" bid="{{ row.b_id }}"> <td>{{ forloop.counter }}</td> <td>{{ row.hostname }}</td> <td>{{ row.ip }}</td> <td>{{ row.port }}</td> <td>{{ row.b.caption }}</td> </tr> {% endfor %} </tbody> </table> <div class="shade hide"> </div> <div class="add_modal hide"> <form action="/cmdb/host" method="post"> <div class="group"> <input type="text" placeholder="主机名" name="hostname"/> </div> <div class="group"> <input type="text" placeholder="IP" name="ip"/> </div> <div class="group"> <input type="text" placeholder="端口" name="port"/> </div> <div class="group"> <select name="b_id"> {% for row in b_list %} <option value="{{ row.id }}">{{ row.caption }}</option> {% endfor %} </select> </div> <input type="submit" value="提交"> <input id="cancel" type="button" value="取消"> </form> </div> <script src="../../static/jquery-3.4.1.js"></script> <script> $(function () { $('#add_host').click(function () { $('.shade,.add_modal').removeClass('hide'); }); $('#cancel').click(function () { $('.shade,.add_modal').addClass('hide'); }); }) </script> </body> </html>