HTML中设置table标签行列背景颜色

在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>
	
    	background-color: #ff94e2;>
    	background-color: #ffae3e;>
    	background-color: #bcff5e;>
	
style>

你可能感兴趣的:(HTML中设置table标签行列背景颜色)