【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;
}
相关推荐
WEI_Gaot17 分钟前
react19 的项目创建和组件使用
前端·react.js
资深前端外卖员21 分钟前
【nodejs高可用】前端APM应用监控方案 + 落地
前端·后端
OhBonsai21 分钟前
Shader 图像处理1_ToneMap技术处理过曝
前端
突头小恐龙21 分钟前
Chrome devTools - Lighthouse
前端·javascript·chrome
谦谦橘子21 分钟前
手写tiny webpack,理解webpack原理
前端·javascript·webpack
土豆125023 分钟前
Tailwind CSS 精通指南:提升效率、可维护性与最佳实践
前端·css
花生了什么树lll23 分钟前
面试中被问到过的前端八股(四)
前端·面试
zqlcoding24 分钟前
使用el-table表格动态渲染表头数据之后,导致设置fixed的列渲染出现问题
前端·javascript·vue.js
爱吃的强哥35 分钟前
vue3 使用 vite 管理多个项目,实现各子项目独立运行,独立打包
前端·javascript·vue.js
谈不譚网安44 分钟前
CSRF请求伪造
前端·网络安全·csrf