响应式表格

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <link rel="stylesheet" type="text/css" href="css/normalize.css"/>
        <link rel="stylesheet" type="text/css" href="css/end.css"/>
    </head>
    <body>
        <h1>响应式表格</h1>
        <table class="responsive">
            <thead>
                <tr>
                    <th>课程序号</th>
                    <th>课程名称</th>
                    <th>课程操作</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="number">150406</td>
                    <td class="name">移动应用开发课程</td>
                    <td class="actions">
                        <a href="#">修改</a><a href="del">删除</a>
                    </td>
                </tr>
                <tr>
                    <td class="number">140407</td>
                    <td class="name">web前端开发课程</td>
                    <td class="actions">
                        <a href="#">修改</a><a href="del">删除</a>
                    </td>
                </tr>
                <tr>
                    <td class="number">140408</td>
                    <td class="name">操作系统&数据库系列课程</td>
                    <td class="actions">
                        <a href="#">修改</a><a href="del">删除</a>
                    </td>
                </tr>
                <tr>
                    <td class="number">140409</td>
                    <td class="name">智能硬件&物联网系列课程</td>
                    <td class="actions">
                        <a href="#">修改</a><a href="del">删除</a>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
/*
 绿色  #35B558
 橙色  #ff5c00
 深灰  #666666
 浅灰  #F8F8F8
 * */
h1{
    font-size: 30px;
    text-align: center;
    color: #666;
}
table.responsive{
    width:98%;
    margin: 0 auto;
    color: #000;
    border-collapse: collapse;
    border: 1px solid #666666;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}
table.responsive td,table.responsive th{
    border: 1px solid #666666;
    padding: .5em 1em;
}
table.responsive th {
    background: #35B558;
    height: 24px;
    line-height: 24px;
}
table.responsive .actions a{
    color: #ff5c00;
    padding: 0 2px;
    text-decoration: none;
}
table.responsive .number,table.responsive .actions{
    text-align: center;
}
@media (max-width:480px){
    table.responsive{
        box-shadow: none;
        border: none;
    }
    table.responsive thead {
        display: none;
    }
    table.responsive tr, table.responsive td {
        display: block;
    }
    table.responsive td:nth-child(1), table.responsive td:nth-child(2) {
        padding-left: 25%;
    }
    table.responsive td:nth-child(1)::before {
        content:'课程序号';
        position: absolute;
        left: .5em;
        font-weight: bold;
    }
    table.responsive td:nth-child(2)::before {
        content:'课程名称';
        position: absolute;
        left: .5em;
        font-weight: bold;
    }
    table.responsive tr {
        position: relative;
        margin-bottom: 1em;
        box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);
    }
    table.responsive td {
        border: none;
    }
    table.responsive .number {
        background: #35B558;
        text-align: left;
    }
    table.responsive td.actions {
        position: absolute;
        top: 0;
        right: 0;
        border: none;
        background: none;
    }
}

 

posted @ 2016-07-04 13:18  灬東歌℡  阅读(150)  评论(0)    收藏  举报