博主信息
博文 7
粉丝 0
评论 0
访问量 7478
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
使用CSS制作一张带有四个圆角的表格--2019-9-6
做么也的博客
原创
782人浏览过

12.png


实例

<!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">
    <style>
        table {
            border: 1px solid black;
            box-shadow: 2px 2px 2px;
            border-spacing: 0;
            border-radius: 20px;
            margin: 0 auto;
            width: 800px;
            position: relative;
        }
        
        th,
        td {
            border: 1px solid black;
            text-align: center;
            margin: 0;
            padding: 0;
            font-weight: bold;
        }
        
        th {
            height: 30px;
            line-height: 30px;
        }
        
        td {
            height: 30px;
            line-height: 30px;
            font-size: 15px;
        }
        /* 设置标题 */
        
        caption {
            font-size: 1.6em;
            font-weight: lighter;
            margin-bottom: 12px;
        }
        /* 设置表头背景 字体颜色 */
        
        tr>th {
            background-color: burlywood;
            color: black;
        }
        /* 设置 第一列 周日-周四 合并表格样式 */
        
        table tbody>tr:nth-of-type(1)>td:nth-of-type(1) {
            background-color: bisque;
            color: black;
            font-weight: bold;
        }
        /* 设置 第一列 周五-周六 合并表格样式 */
        
        table tbody>tr:nth-of-type(3)>td:nth-of-type(1) {
            background-color: bisque;
            color: black;
            font-weight: bold;
        }
        /* 设置最下面 备注行 背景 */
        
        table tbody>tr:last-of-type {
            background-color: darkgray;
        }
        /* 设置 第一列 的 备注 字体 */
        
        table tbody>tr:nth-of-type(5)>td:nth-of-type(1) {
            font-weight: bolder;
        }
        /* 设置备注 框 后面 内容的 样式 */
        
        table tbody>tr:nth-of-type(5)>td:nth-of-type(2) {
            text-align: left;
            padding-left: 15px;
            font-weight: bold;
            color: chartreuse
        }
        /* 设置 背景图片 */
        
        table:before {
            content: "";
            width: 800px;
            height: 311px;
            position: absolute;
            left: 0;
            top: 48px;
            background-image: url("https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2180652589,258881584&fm=26&gp=0.jpg");
            background-size: cover;
            border-radius: 15px;
            opacity: 0.4;
        }
        /* 设置表格左边-左上角圆角 */
        
        table tbody>tr:nth-of-type(1)>th:nth-of-type(1) {
            border-top-left-radius: 15px;
        }
        /* 设置表格右边-右上圆角 */
        
        table tbody>tr:nth-of-type(1)>th:last-of-type {
            border-top-right-radius: 15px;
        }
        /* 设置表格左边-左下角圆角 */
        
        table tbody>tr:nth-of-type(5)>td:nth-of-type(1) {
            border-bottom-left-radius: 15px;
        }
        /* 设置表格右边-右下角圆角 */
        
        table tbody>tr:nth-of-type(5)>td:nth-of-type(2) {
            border-bottom-right-radius: 15px;
        }
    </style>
    <title>Document</title>
</head>

<body>
    <table>
        <thead>
            <caption>***包厢时段表</caption>
            <tr>
                <th id="top">星期</th>
                <th>包厢时段</th>
                <th>至尊卡</th>
                <th>钻石卡</th>
                <th>金卡</th>
                <th>银卡</th>
            </tr>
        </thead>
        <tbody>

            <tr>
                <td rowspan="2">周日<br>|<br>周四</td>
                <td>黄金档<br>18:00-00:00</td>
                <td>4折</td>
                <td>5折</td>
                <td>6折</td>
                <td>7折</td>
            </tr>
            <tr>
                <td>夜猫档<br>00:00-打烊</td>
                <td>4折</td>
                <td>5折</td>
                <td>6折</td>
                <td>7折</td>
            </tr>
            <tr>
                <td rowspan="2">周五<br>|<br>周六</td>
                <td>黄金档<br>18:00-00:00</td>
                <td>4折</td>
                <td>5折</td>
                <td>6折</td>
                <td>7折</td>
            </tr>
            <tr>
                <td>夜猫档<br>00:00-打烊</td>
                <td>4折</td>
                <td>5折</td>
                <td>6折</td>
                <td>7折</td>
            </tr>
            <tr>
                <td>备注</td>
                <td colspan="5">一周内接受定位包厢保留10分钟,逾时取消保留</td>
            </tr>
        </tbody>
    </table>
</body>

</html>

运行实例 »

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

总结:

table  ()设置 border-collapse: separate  以及 boder-radius  圆角,)

再用 border-spacing 设置 table 相邻单元格的边框间 为0 

最后 依次设置  左( 左上 , 左下 )圆角    右( 右上 , 右下 )圆角 

不知道此种方法  有没有什么不妥当的地方,自己的理解也只能做到如此了


批改状态:合格

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

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

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