Python学习第159天(bootstrap练习)

今天主要就是使用bootstrap对之前完成的作业进行优化,至少看起来像个网站了

先回忆一下旧版:

 

 然后是我的新版:

 

每行还设置的鼠标悬浮变色功能,然后将增加学生变成了一个跳出框的模式

 

基本上像那么回事了,但是知识把前端搞定了,后台的连接还没有搞定,勉强把班级信息提前获取到了,现在就展示一下get_students.html的变化吧

之前旧版本:

糟了,直接在旧版本修改,旧的找不到了

那就直接上新版本了:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/plugins/bootstrap/css/bootstrap.css">
    <style>
        .bbq {
            padding: 0px 20px;
        }
    </style>
</head>
<body>
<div class="container">
    <div style="padding: 10px 0px">
        <a class="btn btn-info" href="add_students.html">添加学生</a>
        <a class="btn btn-info" id="addBtn">添加学生(新)</a>
    </div>
    <div>
        <table class="table table-hover table-striped" border="1">
            <thead>
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>班级</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for row in stu_list %}
                <tr class="">
                    <td>
                        {{ row.id }}
                    </td>
                    <td>
                        {{ row.username }}
                    </td>
                    <td>
                        {{ row.age }}
                    </td>
                    <td>
                        {{ row.gender }}
                    </td>
                    <td>
                        {{ row.cs.titile }}
                    </td>
                    <td>
                        <a class="glyphicon glyphicon-remove bbq" href="/del_students.html?nid={{ row.id }}"
                           style="font-size:15px">删除</a>
                        <a class="glyphicon glyphicon-wrench bbq" href="/edit_students.html?nid={{ row.id }}"
                           style="font-size: 15px">编辑</a>
                    </td>
                </tr>

            {% endfor %}

            </tbody>
        </table>
    </div>

    <!-- Modal -->
    <div class="modal fade" id="addModal" 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">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">添加学生</h4>
                </div>
                <div class="modal-body">

                    <form class="form-horizontal">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">姓名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="username" placeholder="姓名">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">年龄</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="age" placeholder="年龄">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="radio" name="gender" value="1"></label>
                                <label class="radio-inline">
                                    <input type="radio" name="gender" value="0"></label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="age" class="col-sm-2 control-label">班级</label>
                            <div class="col-sm-10">
                                <select class="form-control">
                                    <option value="1">
                                        {% for row in cs_list %}
                                            <option value="{{ row.id }}">{{ row.titile }}</option>
                                        {% endfor %}
                                </select>
                            </div>
                        </div>
                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script src="/static/js/jquery-3.1.1.js"></script>
    <script src="/static/plugins/bootstrap/js/bootstrap.js"></script>
    <script>
        $(function () {
            bindEvent();
        });

        function bindEvent() {
            $('#addBtn').click(function () {
                $('#addModal').modal('show');
            })
        }
    </script>
</div>
</body>
</html>

 

 今天 暂时就是这些了,感觉自己棒棒哒。

 

posted @ 2020-09-18 23:58  崆峒山肖大侠  阅读(169)  评论(0编辑  收藏  举报