css3表格练习

1.效果图

2.html

html 复制代码
<div class="line">

    </div>
    <h3>获奖名单</h3>
    <!-- 表格 cellspacing内边距 cellpadding外边距-->
    <table  cellspacing="0" cellpadding="0" >
        <!-- thead表头 -->
        <thead>
            <tr>
                <td>中奖用户</td>
                <td>PR排名</td>
                <td>具体奖品</td>
            </tr>
        </thead>    
        <!-- tbody表体 -->
        <tbody>
            <tr>
                <td>王振民</td>
                <td>1</td>
                <td>
                    <div>一年学费+</div>
                    <div class="warp">特别礼品</div>
                </td>
            </tr>
            <tr>
                <td>王振民</td>
                <td>1</td>
                <td>
                    <div>一年学费+</div>
                    <div class="warp">特别礼品</div>
                </td>
            </tr>
            <tr>
                <td>王振民</td>
                <td>1</td>
                <td>
                    <div>一年学费+</div>
                    <div class="warp">特别礼品</div>
                </td>
            </tr>
            <tr>
                <td>王振民</td>
                <td>1</td>
                <td>
                    <div>一年学费+</div>
                    <div class="warp">特别礼品</div>
                </td>
            </tr>
            <tr>
                <td>王振民</td>
                <td>1</td>
                <td>
                    <div>一年学费+</div>
                    <div class="warp">特别礼品</div>
                </td>
            </tr>
            <tr>
                <td>王振民</td>
                <td>1</td>
                <td>
                    <div>一年学费+</div>
                    <div class="warp">特别礼品</div>
                </td>
            </tr>
        </tbody>
        <!-- tfoot表尾 -->
        <tfoot>
            <!-- <tr>
                <td>总计</td>
                <td colspan="2">共100名</td>
            </tr> -->
        </tfoot>
    </table>

3.css

css 复制代码
*{
    padding: 0;
    margin: 0;
    list-style-type: none;
}
.line{
	width: 330px;
	height: 1px;
	border-top: 1px solid #7ef805;
	margin: 0 auto;
	margin-top: 50px;
}
h3{
	width: 100px;
	text-align: center;
    /* 关键点,利用定位让文字居中 */
	position: relative;
	margin: 0 auto;
	bottom: 14px;
	background-color: white;
	color: #7ef805;
}
table{
    width: 330px;
    /* margin: 0 auto;居中 */
    margin: 0 auto; 
    text-align: center;
    vertical-align: middle;
}

table tr td{
    /* width: 10%; */
    height: 50px;
}
/* 去除表格四周边框 */
table td{
    border: 1px solid blue;
    /* 上边框和左边框为0 */
    border-top: 0;
    border-left: 0;
}
table td:nth-child(3){
    border-right: 0;
}
/* 站在父元素的角度上选择最后一个子元素 */
table tbody tr:last-child td{
    border-bottom: 0;
}
thead{
    background-color: #7ef805;
    color: white;
}
.warp{
    /* font-size: 10px; */
    font-weight: bolder;
}
/* 隔行变色 */
tbody tr:nth-child(odd){
    background-color: #7ef805;
}
tbody tr:nth-child(even){
    background-color: red;
}
tbody tr{
    border: 1px solid red;
}
相关推荐
晓得迷路了4 分钟前
栗子前端技术周刊第 84 期 - Vite v7.0 beta、Vitest 3.2、Astro 5.9...
前端·javascript·vite
独立开阀者_FwtCoder7 分钟前
最全301/302重定向指南:从SEO到实战,一篇就够了
前端·javascript·vue.js
Moment16 分钟前
给大家推荐一个超好用的 Marsview 低代码平台 🤩🤩🤩
前端·javascript·github
小满zs20 分钟前
Zustand 第三章(状态简化)
前端·react.js
普宁彭于晏21 分钟前
元素水平垂直居中的方法
前端·css·笔记·css3
恋猫de小郭33 分钟前
为什么跨平台框架可以适配鸿蒙,它们的技术原理是什么?
android·前端·flutter
云浪36 分钟前
元素变形记:CSS 缩放函数全指南
前端·css
明似水1 小时前
用 Melos 解决 Flutter Monorepo 的依赖冲突:一个真实案例
前端·javascript·flutter
独立开阀者_FwtCoder1 小时前
stagewise:让AI与代码编辑器无缝连接
前端·javascript·github
清沫1 小时前
Cursor Rules 开发实践指南
前端·ai编程·cursor