博客列表 >CSS多样式表格设计——2019年9月6号20:00

CSS多样式表格设计——2019年9月6号20:00

虎子爸爸
虎子爸爸原创
2019年09月07日 11:49:23664浏览

效果图:

table-3.png

上码:

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style2.css">
    <title>css控制表格的样式</title>
</head>

<body>
    <style>
        /*给表格加上边框*/
        
        table {
            border: 1px solid #444444;
            border-collapse: collapse;
            width: 800px;
            margin: 20px auto;
        }
        
        th,
        td {
            border: 1px solid #444444;
            text-align: center;
            padding: 10px;
        }
        
        table caption {
            font-size: 1.3rem;
            /*文本加粗*/
            font-weight: bolder;
            margin-bottom: 15px;
        }
        /* 第一行 */
        
        #table-head-tr {
            background-color: lightgreen;
        }
        /* 第一行 */
        
        table thead>tr:first-of-type {
            /* background-color: lightgreen; */
            color: cornflowerblue;
        }
        
        table tbody>tr:first-of-type>td:first-of-type {
            background-color: wheat;
        }
        
        table tbody>tr:nth-last-of-type(1)>td:first-of-type {
            background-color: crimson;
            color: darkorange;
        }
        /*圆角表格样式*/
        /* 第一行左 */
        
        table tr:first-child th:first-child {
            border-top-left-radius: 12px;
        }
        /* 第一行右 */
        
        table tr:first-child th:last-child {
            border-top-right-radius: 12px;
        }
        /* 最后一行左 */
        
        table tr:last-child td:first-child {
            border-bottom-left-radius: 12px;
        }
        /* 最后一行右 */
        
        table tr:last-child td:last-child {
            border-bottom-right-radius: 12px;
        }
    </style>
    <table>
        <!--    标题-->
        <caption>小猪一天的喂食</caption>
        <!--    表头-->
        <thead>
            <tr id="table-head-tr">
                <th>时间</th>
                <th>星期一</th>
                <th>星期二</th>
                <th>星期三</th>
                <th>星期四</th>
                <th>星期五</th>
            </tr>
        </thead>

        <!--    主体-->
        <tbody>
            <tr>
                <td rowspan="3">上午<br>8:00 - 11:30</td>
                <td>糠</td>
                <td>树叶</td>
                <td>咸菜</td>
                <td>豆饼</td>
                <td>摩胃石</td>
            </tr>
            <tr>

                <td>糠</td>
                <td>树叶</td>
                <td>咸菜</td>
                <td>豆饼</td>
                <td>摩胃石</td>
            </tr>
            <tr>

                <td>糠</td>
                <td>树叶</td>
                <td>咸菜</td>
                <td>豆饼</td>
                <td>摩胃石</td>
            </tr>

            <tr>
                <td rowspan="2">下午<br>13:30 - 15:30</td>
                <td>糠</td>
                <td>树叶</td>
                <td>咸菜</td>
                <td>豆饼</td>
                <td>摩胃石</td>
            </tr>
            <tr>

                <td>糠</td>
                <td>树叶</td>
                <td>咸菜</td>
                <td>豆饼</td>
                <td>摩胃石</td>
            </tr>


            <tr>
                <td>晚餐</td>
                <td colspan="5">米酒汤圆</td>
            </tr>

        </tbody>

    </table>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议
Damon2019-09-07 22:19:231楼
有没有在非微软浏览器里调试啊?在谷歌、火狐浏览器里圆角有问题