【Web应用技术基础】CSS(5)——表格样式

第一题:表格边框

.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>HTML -- 简单表格</title>
        <link rel="stylesheet" href="step1/CSS/style.css">
    </head>

    <body>
        <table>
            <caption>彩排安排</caption>
            <thead>
                <!-- 表格头部 -->
                <tr>
                    <th scope="rowgroup">时间</th>
                    <th scope="col">周一</th>
                    <th scope="col">周二</th>
                    <th scope="col">周三</th>
                </tr>
            </thead>
            <tbody>
                <!-- 表格主体 -->
                <tr>
                    <th scope="row">上午8点</th>
                    <td>开场舞</td>
                    <td colspan="2">歌曲串烧</td>
                </tr>
                <tr>
                    <th scope="row">上午9点</th>
                    <td>小品</td>
                    <td>相声</td>
                    <td rowspan="2">大型魔术</td>
                </tr>
                <tr>
                    <th scope="row">上午10点</th>
                    <td>杂艺表演</td>
                    <td>乐队歌曲</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

.css

table {
    /* ********** BEGIN ********** */
    border-collapse: collapse; /*设置折叠边框*/
    border: 2px solid black;
    
    /* ********** END ********** */
}

th,
td {
    padding: .5em .75em;
}

th {
    /* ********** BEGIN ********** */
     border: 1px solid grey;
    /* ********** END ********** */
}

td {
    /* ********** BEGIN ********** */
    border: 1px dotted grey;
    /* ********** END ********** */
}

第二题:表格颜色、文字与大小

.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>HTML -- 简单表格</title>
        <link rel="stylesheet" href="step2/CSS/style.css">
    </head>
    <body>
        <table>
            <caption>彩排安排</caption>
            <thead>
                <!-- 表格头部 -->
                <tr>
                    <th scope="rowgroup">时间</th>
                    <th scope="col">周一</th>
                    <th scope="col">周二</th>
                    <th scope="col">周三</th>
                    <th scope="col">周四</th>
                </tr>
            </thead>
            <tbody>
                <!-- 表格主体 -->
                <tr>
                    <th scope="row">上午8点</th>
                    <td>开场舞</td>
                    <td colspan="3">歌曲串烧</td>
                </tr>
                <tr>
                    <th scope="row">上午9点</th>
                    <td>小品</td>
                    <td>相声</td>
                    <td rowspan="2">大型魔术</td>
                    <td>乐队歌曲</td>
                    
                </tr>
                <tr>
                    <th scope="row">上午10点</th>
                    <td>杂艺表演</td>
                    <td>乐队歌曲</td>
                    <td>杂艺表演</td>
                    
                </tr>
                <tr>
                    <th scope="row">上午8点</th>
                    <td>开场舞</td>
                    <td>歌曲串烧</td>
                    <td>小品</td>
                    <td>相声</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

.css

table {
    border-collapse: collapse;
    border: 2px solid black;
}

caption {
    /* ********** BEGIN ********** */
    font-size: 20px;
    font-weight: bold;
    height: 40px;



    /* ********** END ********** */
}

th,
td {
    /* ********** BEGIN ********** */
    height: 50px;
    width: 100px;
    text-align: center;
    /* ********** END ********** */
}

th {
    /* ********** BEGIN ********** */
    border: 1px solid white;
    background-color: lightseagreen;
    color: white;

    /* ********** END ********** */
}

td {
    border: 1px solid grey;
}
相关推荐
汪子熙10 分钟前
Angular 服务器端应用 ng-state tag 的作用介绍
前端·javascript·angular.js
Envyᥫᩣ19 分钟前
《ASP.NET Web Forms 实现视频点赞功能的完整示例》
前端·asp.net·音视频·视频点赞
Мартин.4 小时前
[Meachines] [Easy] Sea WonderCMS-XSS-RCE+System Monitor 命令注入
前端·xss
昨天;明天。今天。6 小时前
案例-表白墙简单实现
前端·javascript·css
数云界6 小时前
如何在 DAX 中计算多个周期的移动平均线
java·服务器·前端
风清扬_jd6 小时前
Chromium 如何定义一个chrome.settingsPrivate接口给前端调用c++
前端·c++·chrome
安冬的码畜日常6 小时前
【玩转 JS 函数式编程_006】2.2 小试牛刀:用函数式编程(FP)实现事件只触发一次
开发语言·前端·javascript·函数式编程·tdd·fp·jasmine
ChinaDragonDreamer6 小时前
Vite:为什么选 Vite
前端
小御姐@stella6 小时前
Vue 之组件插槽Slot用法(组件间通信一种方式)
前端·javascript·vue.js
GISer_Jing6 小时前
【React】增量传输与渲染
前端·javascript·面试