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;
}
相关推荐
kyriewen8 小时前
Webpack vs Vite:一个是“老黄牛”,一个是“猎豹”,你选谁?
前端·webpack·vite
打小就很皮...8 小时前
html2canvas + jsPDF 生成 PDF 的踩坑与解决方案总结
前端·pdf
全栈前端老曹8 小时前
【前端地图】多地图平台适配方案——高德、百度、腾讯、Google Maps SDK 差异对比、封装统一地图接口
前端·javascript·百度·dubbo·wgs84·gcj-02·bd09
雾岛听风6919 小时前
JavaScript基础语法速查手册
开发语言·前端·javascript
遇见~未来9 小时前
第三篇_现代布局_从弹性到网格
前端·css3
前端那点事9 小时前
Vue前端SEO优化全攻略(实操落地版,新手也能上手)
前端·vue.js
Dxy12393102169 小时前
HTML 如何使用 SVG 画曲线
前端·算法·html
用户2367829801689 小时前
从零实现 GIF 制作工具:LZW 压缩与 Median Cut 色彩量化
前端·javascript
hahaha 1hhh9 小时前
中文乱码 ubuntu autodl
linux·运维·前端
Codebee10 小时前
Harness Engineering:AICode 的灵魂
前端·人工智能·前端框架