0
I have a table, and I want the lines to intersperse colors the way below works perfectly
<style type="text/css">
.tabela_parametros_gerais tr{height: 20px !important;}
.tabela_parametros_gerais tr td{padding-left : 5px;}
.tabela_parametros_gerais tr:hover {background-color: #E4E1C9 !important;}
.tabela_parametros_gerais tr:nth-child(even) {background-color: #FFFFFF;}
.tabela_parametros_gerais tr:nth-child(odd) {background-color: #ECFFEE;}
</style>
the problem is that the colors established there, must come from another class list_cor_sim and list_cor_nao, I saw a way to do this using Less/Sass/Cs-modules but I can’t use them because the project I’m modifying does not use, and I can’t add - los
https://stackoverflow.com/questions/4564916/nesting-css-classes
example of how to "wish" it worked
<style type="text/css">
.cor_hover{background-color: #E4E1C9;}
.list_cor_sim{background-color: #ECFFEE;}
.list_cor_nao{background-color: #FFFFFF;}
.tabela_parametros_gerais tr{height: 20px !important;}
.tabela_parametros_gerais tr td{padding-left : 5px;}
.tabela_parametros_gerais tr:hover {.cor_hover() !important;}
.tabela_parametros_gerais tr:nth-child(even) {.list_cor_nao();}
.tabela_parametros_gerais tr:nth-child(odd) {.list_cor_sim();}
</style>
with javascript, I am unable to add mouseouver and mouseout (addeventlistener is not working)
function zebrar() {
var table = document.getElementById("tabela_parametros_gerais");
for (var i = 0, row; row = table.rows[i]; i++) {
var cor;
if(i % 2 === 0){
cor = "list_cor_sim";
}else{
cor = "list_cor_nao";
}
row.classList.add(cor);
}
}
.list_cor_sim {background: red}
and.list_cor_nao {background: blue}
... your doubt was not clear– hugocsl
currently already exists the classes list_cor_nao and list_cor_sim, and I need to use them to know which color to add, understand?
– Henrique Lemes Baron
.tabela_parametros_gerais tr.list_cor_nao:nth-child(even) { }
have tried?– hugocsl
I tried now and it didn’t work
– Henrique Lemes Baron