码迷,mamicode.com
首页 > 其他好文 > 详细

响应式之表格

时间:2016-01-29 21:18:11      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="begin1.css">
</head>
<body>
    <h1>响应式表格</h1>
    <table class="responsive">
        <thead>
            <tr>
                <th>课程序号</th>
                <th>课程名称</th>
                <th>课程操作</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="number">150405</td>
                <td class="name">移动应用开发课程</td>
                <td class="action"><a href="#">修改</a><a href="#">删除</a></td>
            </tr>
        </tbody>
        <tbody>
            <tr>
                <td class="number">150406</td>
                <td class="name">数据库orcle</td>
                <td class="action"><a href="#">修改</a><a href="#">删除</a></td>
            </tr>
        </tbody>
        <tbody>
            <tr>
                <td class="number">150407</td>
                <td class="name">HTML5开发</td>
                <td class="action"><a href="#">修改</a><a href="#">删除</a></td>
            </tr>
        </tbody>
        <tbody>
            <tr>
                <td class="number">150408</td>
                <td class="name">编译原理</td>
                <td class="action"><a href="#">修改</a><a href="#">删除</a></td>
            </tr>
        </tbody>
    </table>
</body>
</html>

---------------------------------------------分割线看什么看-------------------------------------------------------------

h1{
    font-size: 30px;
    text-align: center;
    line-height: 30px;
    color: #666666;
}
table.responsive{
    margin: 0 auto;
    width: 98%;
    border: 1px solid #ccc;
    box-shadow: 0 0 10px 0 #555;
}
table.responsive th,table.responsive td{
    border: 1px solid #ccc;
    padding: .5em 1em;
}
table.responsive th{
    background-color: #0f0;
}
table.responsive td.action a{
    color:#ff5c00;
    text-decoration: none;    
    padding: 0 5px;
}
table.responsive .number,table.responsive .action{
    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;
        border: none;
        position: relative;
    }
    table.responsive .number{
        text-align: left;
        background-color: #0f0;
        padding-left: 28%;
    }
    table.responsive .number::before{
        content: "课程序号";
        position: absolute;
        left: .5em;
        top: .5em;
        font-weight: bold;
    }
    table.responsive .name{
        text-align: left;
        padding-left: 28%;
    }

    table.responsive .name::before{
        content: "课程名称";
        position: absolute;
        left: .5em;
        top: .5em;
        font-weight: bold;
    }
    table.responsive .action{
        position: absolute;
        right: 0;
        top: 0;
    }
    table.responsive tr{
        margin-bottom: .5em;
        box-shadow: 0 1px 10px 0 #888;
    }
}

 

效果如图:

宽度大于480px:

技术分享

 

宽度小于480px:

技术分享

响应式之表格

标签:

原文地址:http://www.cnblogs.com/xianhaiyuan/p/5169885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!