Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
May your rolls be merry + bright! 🎄
Create a free account

CSS - Repeating DIV background colour

1605210486

Edited 1605210541
Hi all, I'm trying to get an alternating background colour for a list of div containers using the nth-child feature. However, when I apply it to the div, it applies it to every even div container, and every even div within the div container. I only need it to select every even div container. <rolltemplate class="sheet-rolltemplate-vaesen-table">     <div class="container">         <caption><h1>{{name}}</h1></caption>         <div class="arrow-container"><div class="arrow-right"></div></div>             <div class="list">             {{#allprops()}}                <div class="sheet-flex"><div class="key">{{key}}</div><div class="value">{{value}}</div></div>             {{/allprops()}}             </div>     </div> </rolltemplate> CSS: .sheet-rolltemplate-vaesen-table .sheet-list div:nth-child(even) {     background-color: #fff; }
1605210999
Finderski
Plus
Sheet Author
Compendium Curator
On a call, but I believe the issue is you're specifying a div after the list class.  Try this: .sheet-rolltemplate-vaesen-table div.sheet-list:nth-child(even) { background-color: #fff; }
1605213661

Edited 1605213692
Thanks for the help. But now it's not catching any of the divs
1605217761
Caden
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Try .sheet-rolltemplate-vaesen-table .sheet-list div.sheet-flex:nth-of-type(even) {     background-color: #fff; }
That did it! Thank you for the help!
1605300250
Caden
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You're welcome