在css选择器中进行设置:

使用tr:nth-child(5n)可以自己设置每隔多少行设置一种颜色。

也可以使用tr:odd{ }设置奇数行,tr:even{}设置偶数行

<style>
        tr:nth-child(5n){
            background-color: #ff94e2;
        }
        tr:nth-child(5n+1){
            background-color: #ffae3e;
        }
        tr:nth-child(5n+2){
            background-color: #bcff5e;
        }
        tr:nth-child(5n+3){
            background-color: #38ffca;
        }
        tr:nth-child(5n+4){
            background-color: #58b2ff;
        }
        table {
            border-collapse: collapse;
        }
    </style>

使用标签可以设置每一列设置不同颜色;

<style>
	<colgroup>
    	<col background-color: #ff94e2;>
    	<col background-color: #ffae3e;>
    	<col background-color: #bcff5e;>
	</colgroup>
</style>
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐