javascript - 怎么修改能让这两个表格都实现十字变色
ringa_lee
ringa_lee 2017-04-10 15:08:04
[JavaScript讨论组]

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5




1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
ringa_lee
ringa_lee

ringa_lee

全部回复(2)
PHP中文网

你这个ID为“tb1”的元素是第一个表格吗?能提供更多信息吗?

阿神

Css版

csstr:nth-child(2n)>td:nth-child(2n) {
    color: #333;
    background-color: green;
}

tr:nth-child(2n)>td:nth-child(2n+1) {
    color: #666;
    background-color: blue;
}

tr:nth-child(2n+1)>td:nth-child(2n) {
    color: #666;
    background-color: blue;
}

tr:nth-child(2n+1)>td:nth-child(2n+1) {
    color: #333;
    background-color: green;
}

Scss版

scss@mixin style1 {
    color: #333;
    background-color: green;
}

@mixin style2 {
    color: #666;
    background-color: blue;
}

tr {
    &:nth-child(2n) {
        &>td:nth-child(2n) {
            @include style1;            
        }
        &>td:nth-child(2n+1) {
            @include style2;
        }
    }
    &:nth-chlid(2n+1) {
        &>td:nth-child(2n) {
            @include style2;
        }
        &>td:nth-child(2n+1) {
            @include style1;
        }
    }
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

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