I would like to make a similar style of reddit comment.
Like that:
<div>
<div class="comment" style="background: white;">
<div class="comment" style="background: grey;"></div>
<div class="comment" style="background: grey;">
<div class="comment" style="background: white;">
<div class="comment" style="background: grey;"></div>
</div>
</div>
<div class="comment" style="background: white;"></div>
</div>
I'm looking for doing this with my situation
Actually my html code is generate by Rails and look like that
<div class="comment_main-list>
<div class="comment_list">
<div class="comment">blabla</div>
<div class="comment_main-list>
<div class="comment_list>
<div class="comment">answer to blabla</div>
</div>
</div>
</div>
<div class="comment_list">...</div>
</div>
I tried to take something like that
.comment_list{
background: #ececec;
.comment_list{
background: #dfdfdf;
.comment_list{
background: #ececec;
}
}
Obviously it work but I can't do that for an undefined times, I tried to take a look to the loop in sass but I don't know how to know the number of comment in advance.
Also nth:child
or nth:type
doesn't do what I want.
Do you have any idea on how I can do that ?
Thank you