前端零基础入门 /升级页面化妆师CSS/CSS选择器/2-29编程练习

2-29 编程练习

 

根据效果图,补充代码,实现:

(1)   表格的表头背景颜色是黄色

(2)   表格主体的奇数行字体颜色是橘色,偶数行字体颜色是绿色

要求:选择器均用:nth-child(odd)和:nth-child(even)

效果图如下:

//climg.mukewang.com/582c230f0001ff9a03890207.jpg

 

任务

 

第一步:给表格的表头设置背景颜色,表格的表头是第一行

第二步:将表格中行的奇数项字体颜色设置为橘色,表格中行的偶数项字体颜色设置为绿色

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>:nth-child()</title>
    <style type="text/css">
        thead {
            background: yellow;
        }
        tbody > tr:nth-child(odd) {
            color: orange;
            }
        tbody > tr:nth-child(even) {
            color: green;
            }/*此处补充样式*/
    </style>
</head>
<body>
    <table border="1" cellspacing="0" width="200">
        <thead>
            <tr>
                <th>序号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年纪</th>
            </tr>
        </thead>
        <tbody> 
            <tr>
                <td>1</td>
                <td>张三</td>
                <td>男</td>
                <td>12</td>
            </tr>
            <tr>
                <td>2</td>
                <td>李四</td>
                <td>女</td>
                <td>11</td>
            </tr>
            <tr>
                <td>3</td>
                <td>赵五</td>
                <td>男</td>
                <td>12</td>
            </tr>
            <tr>
                <td>4</td>
                <td>王二</td>
                <td>男</td>
                <td>12</td>
            </tr>
        </tbody>  
    </table>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值