Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

background color every other row in SASS

I'm using Ruby on Rails. I have a .sass file for a datagrid. I'd like every other row to have a different colored background.

I tried this:

tr:nth-child(2n+1) 
    background-color: #E3E3E3   

What should it be?

Thanks

like image 259
Reddirt Avatar asked Dec 06 '25 02:12

Reddirt


2 Answers

This is generally what's used to every-other items:

tr:nth-of-type(odd) {
  background-color:#E3E3E3;
}
like image 188
Jesse Wolgamott Avatar answered Dec 07 '25 19:12

Jesse Wolgamott


For me that works:

[hauleth@NIUNIOBOOK] ~ $ sass
tr:nth-child(2n+1) 
    background-color: #E3E3E3
^D
tr:nth-child(2n+1) {
  background-color: #e3e3e3; }

So what do you wanna get other?

like image 36
Hauleth Avatar answered Dec 07 '25 19:12

Hauleth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!