Blogger Information
Blog 8
fans 0
comment 0
visits 4717
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS制作一张带有四个圆角的表格-2019年9月6日
zzc111的博客
Original
502 people have browsed it

表格加上圆角

实例

<!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">
    <title>css设置表格</title>
    <style>
        table {
            width: 800px;
            margin: 20px auto;
            border-collapse: separate;
            border-spacing: 0;
            position: relative;
        }
        
        th,
        td {
            border: 1px solid black;
            text-align: center;
            padding: 10px;
            font-weight: bolder
        }
        /* 标题样式 */
        
        table caption {
            font-size: 1.3rem;
            font-weight: bolder;
            margin-bottom: 15px;
        }
        /* 设置表格圆角样式 */
        
        table thead tr:first-child th:first-child {
            border-top-left-radius: 20px;
        }
        
        table thead tr:first-child th:last-child {
            border-top-right-radius: 20px;
        }
        
        table tfoot tr:last-child td:first-child {
            border-bottom-left-radius: 20px;
        }
        
        table tfoot tr:last-child td:last-child {
            border-bottom-right-radius: 20px;
        }
        /* 表格添加背景图 */
        
        table:before {
            /*设置伪元素的内容,大小, 位置*/
            content: '';
            width: 799px;
            height: 300px;
            position: absolute;
            left: 0;
            top: 42px;
            /*设置伪元素的背景*/
            background-image: url("xx.jpg");
            background-size: cover;
            opacity: 0.5;
            border-radius: 20px;
        }
    </style>

</head>

<body>



    <table>


        <!-- 标题 -->
        <caption>课程表</caption>
        <!-- 表头 -->
        <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>13:00-15: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>
    </table>


</body>

</html>

运行实例 »

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

总结:

使用子元素选择器选择表格上下左右四个角添加圆角属性


Correction status:qualified

Teacher's comments:看来你对表格线折叠的属性有了认识, 不错
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments