相关疑难解决方法(0)

如何在表格中交替列背景颜色?

这听起来很简单,但我找不到很多关于它的帖子.

基本上我想要第一列红色,第二列绿色,第三红色等......

我怎么能在CSS中做到这一点?

这是我的HTML代码(我正在使用bootstrap 3):

        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Welsh</th>
                    <th>English</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Shwmae <a href="#" onclick="playAudio('shwmae');"><span class="glyphicon glyphicon-volume-up play"></span></a></td>
                    <td>Hello</td>
                </tr>
                <tr>
                    <td>Bore da <a href="#" onclick="playAudio('boreda');"><span class="glyphicon glyphicon-volume-up play"></span></a></td>
                    <td>Good morning</td>
                </tr>
                <tr>
            </tbody>
        </table>
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下CSS,但它没有做任何事情:

col:first-child {background: #FF0}
col:nth-child(2n+3) {background: #CCC}
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap

3
推荐指数
1
解决办法
3260
查看次数

CSS3在IE8上甚至按不同的颜色排列

我有Css代码用于区分不同颜色的奇数和偶数行

.historyLog tr:nth-child(odd) td {
background-color:blue;
}
.historyLog tr.odd td{
    background-color: blue;
}
?
.historyLog tr:nth-child(even) td {
background-color:orange;
}
.historyLog tr.even td{
    background-color: orange;
}
Run Code Online (Sandbox Code Playgroud)

并拥有类.historyLog的表

<table class="historyLog">
<tr><td></td></tr>
<tr><td></td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我使用class属性.historyLog i.ie应用Css时

.historyLog tr:nth-child(odd) td {
background-color:blue;
}
Run Code Online (Sandbox Code Playgroud)

IE8不执行它,我会得到的是所有行的相同颜色,无论是偶数还是奇数.但是如果我在不使用表的class属性的情况下应用css即

tr:nth-child(odd) td {
background-color:blue;
}
Run Code Online (Sandbox Code Playgroud)

然后IE8用不同颜色的奇数偶数行执行它.请帮我解释IE8如何使用table的class属性以不同颜色显示奇数和偶数行.

internet-explorer css3 internet-explorer-8

2
推荐指数
2
解决办法
2万
查看次数