CSS是指每个奇怪的嵌套的孩子? [英] CSS refer to every odd nested child?
问题描述
我试图做一个评论系统,其中嵌套评论有斑马背景颜色。 (蓝色bg回复白色bg回复蓝色bg ...)
I'm trying to make a comment system where nested comments have zebra background colors. (Blue bg replies to white bg replies to blue bg...)
而不是将这些引用为.comment,.comment .comment .comment,.comment .comment .comment,.comment,.comment ......,是否有办法引用这些嵌套的孩子?
Instead of referring to these as .comment, .comment .comment .comment, .comment .comment .comment, .comment, .comment ......, is there a way to refer to these nested children?
***我只能访问
推荐答案
您可以添加一个交替类来伴随 .comment
是在程序中应用的,因为评论正在页面上(例如: .row1
, .row2
等),然后用CSS对这些类进行相应的样式。
You could add an alternating class to accompany .comment
that's applied procedurally as the comments are being laid out on the page (e.g: .row1
, .row2
, etc.) and then style those classes accordingly with CSS.
这篇关于CSS是指每个奇怪的嵌套的孩子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!