博主信息
博文 26
粉丝 1
评论 2
访问量 27112
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
9月6日实战做有四个圆角的表格
星空的博客
原创
949人浏览过

实例

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../0906/css/bg1.css">
    <title>CSS表格作业</title>

</head>

<body>
    <table>
        <!-- 标题 -->
        <caption>
            <h3>合肥市科大附小一年级(3班)课程表</h3>
            <!-- 表头 -->
            <thead>
                <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>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>
            </tbody>
            <!-- 表位 -->
            <tfoot>
                <tr>
                    <td>备注:</td>
                    <td colspan="5">周末家长必须来学校帮助孩子打扫卫生</td>
                </tr>
            </tfoot>
        </caption>
    </table>
</body>

</html>

运行实例 »

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

实例

/* 给表格加上边框 */

table {
    border: 1px solid #444444;
    border-radius: 10px;
}

th,
td {
    border: 1px solid #444444;
}


/* 折叠边框线 */


/* table {
    border-collapse: collapse;
} */


/* 设置表格的宽度,文本居中 */

table {
    width: 800px;
    margin: 20px auto;
}

th,
td {
    text-align: center;
    padding: 10px;
}


/* 表格的标题设置 */

table caption {
    font-size: 1.3rem;
    font-weight: bolder;
    margin-bottom: 15px;
}


/* 设置表头背景颜色 */

table thead tr:first-of-type {
    background-color: lightgreen;
    border-radius: 20px;
}


/* 设置主体第1列,第二行背景颜色 */

table tbody>tr:first-of-type>td:first-of-type {
    background-color: wheat;
}


/* 设置主体第1列,倒数第二行背景颜色 */

table tbody>tr:nth-last-of-type(2)>td:first-of-type {
    background-color: wheat;
}


/* 设置表位背景色 */

table tfoot>tr:first-of-type {
    background-color: lightgray;
    border-radius: 20px;
}


/* 设置表格阴影 */

table {
    box-shadow: 2px 2px 2px #888888;
}


/* 用伪类类型选择器设置表格主体课程背景颜色 */

table tbody>tr:nth-of-type(1)>td,
table tbody>tr:nth-of-type(2)>td,
table tbody>tr:nth-of-type(3)>td,
table tbody>tr:nth-of-type(4)>td,
table tbody>tr:nth-of-type(5)>td {
    background-color: goldenrod;
}


/* 学习用伪类元素设置背景图片 */

table {
    position: relative;
}

table:before {
    content: "";
    width: 800px;
    height: 288px;
    position: absolute;
    left: 0;
    top: 96px;
    /* 添加伪元素背景 */
    background-image: url("http://pic65.nipic.com/file/20150417/3302065_045530101485_2.jpg");
    opacity: 0.1;
    border-radius: 10px;
}


/*设置表格圆角*/

table thead tr:nth-of-type(1)>th:nth-of-type(1) {
    border-radius: 10px 0 0 0;
}

table thead tr:nth-of-type(1)>th:nth-of-type(6) {
    border-radius: 0 10px 0 0;
}

table tfoot tr:nth-of-type(1)>td:nth-of-type(1) {
    border-radius: 0 0 0 10px;
}

table tfoot tr:last-of-type td:last-of-type {
    border-radius: 0 0 10px 0;
}


/* 去掉表格,表位,主体的外边框线 */

table thead tr th {
    border-top: none;
}

table tbody tr td:last-of-type {
    border-right: none;
}

table tfoot tr td {
    border-bottom: none;
}

table thead tr:first-of-type>th:first-of-type {
    border-left: none;
}

table thead tr:last-of-type>th:last-of-type {
    border-right: none;
}

table tfoot tr:first-of-type>td:first-of-type {
    border-left: none;
}

table tfoot tr:last-of-type>td:last-of-type {
    border-right: none;
}

table tbody>tr:nth-of-type(1)>td:nth-of-type(1) {
    border-left: none;
}

table tbody>tr:nth-of-type(4)>td:nth-of-type(1) {
    border-left: none;
}

运行实例 »

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

总结:去某度查询了用border-radius属性设置4圆角;

去掉了折叠边框线border-collapse不能和border-radius一起用,

不然后者会失效。

再单独把去掉表格第一排的左 上 右 边重叠线;主体,表位,第1列排的左 边重叠线,主体,表位,第6列排的右边重叠线,

最后是去掉 表位的下边重叠线!



批改状态:合格

老师批语:这个总结相当的给力, 记住哟
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
1条评论
如水 2019-09-09 13:01:04
技术扎实,学习榜样!
1楼
作者最新博文
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学