【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;
}
相关推荐
午后书香6 分钟前
一天三场面试,口干舌燥要晕倒(二)
前端·javascript·面试
Book_熬夜!21 分钟前
CSS—补充:CSS计数器、单位、@media媒体查询
前端·css·html·媒体
几度泥的菜花1 小时前
如何禁用移动端页面的多点触控和手势缩放
前端·javascript
狼性书生1 小时前
electron + vue3 + vite 渲染进程到主进程的双向通信
前端·javascript·electron
肥肠可耐的西西公主1 小时前
前端(AJAX)学习笔记(CLASS 4):进阶
前端·笔记·学习
拉不动的猪2 小时前
Node.js(Express)
前端·javascript·面试
Re.不晚2 小时前
Web前端开发——HTML基础下
前端·javascript·html
几何心凉2 小时前
如何处理前端表单验证,确保用户输入合法?
前端·css·前端框架
浪遏2 小时前
面试官😏: 讲一下事件循环 ,顺便做道题🤪
前端·面试
Joeysoda2 小时前
JavaEE进阶(2) Spring Web MVC: Session 和 Cookie
java·前端·网络·spring·java-ee