表格行着色 [英] Colouring of table rows alternatively

查看:100
本文介绍了表格行着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了一个使用催化剂,CSS和html的网页.在所有浏览器中都可以正常工作.我在网页中有表格,这些表格的列可以排序(升序或降序).我已经为表格的行上色了.所有表看起来都不错,行交替进行了着色,但是其中一个表的确显示了这种颜色,直到启用排序或单击/选择任何表单元格为止.

I have designed a web page using catalyst, CSS and html. It is working fine in all browsers. I have tables in web page and columns for these tables can be sorted(ascending or descending order). I have coloured the rows of the tables alternatively. All the tables are looking fine with rows alternatively colored, but one of the table does show this colouration until the sorting is enabled or any table cell is clicked/selected.

我不明白为什么会这样.我恳请某人在这方面帮助我,并告诉我为什么会这样以及如何解决这个问题.

I am not understanding why this is happening.I kindly request someone to help me with this regard and tell me why this would happen and how to resolve this problem.

预先感谢和问候

我尝试了这个,但是没有用.如果您能以简单的方式进行解释,将对您有所帮助,因为我是使用教程进行编程和创建Web应用程序的新手.

I tried this but its not working. I would be helpful if you could explain it in simple way, as I am new to programming and creating web applications using tutorials.

推荐答案

只需使用此样式(将颜色更改为所需的颜色)即可将CSS应用于表格:

Just use this (change the color to what you need) CSS applied to your table:

table tr:nth-child(even)
{
    background-color: #F7F7FF;
}

几乎所有浏览器都很好地支持它,但是IE仅在版本9中添加了支持.如果必须支持IE6-8,则可以使用 selectivizr .您可以使用所需的所有标准选择器来编写CSS,它将为您解决问题,当您放弃IE8支持时,只需删除include,没有JavaScript技巧和一个标准CSS.

It's well supported in almost every browser but IE added support only with version 9. If supports for IE6-8 is mandatory you may use selectivizr. You write your CSS with all the standard selectors you need and it'll do the trick for you, when you'll drop IE8 support you simply have to remove the include, no JavaScript tricks all around and one standard CSS.

这篇关于表格行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆