CSS是指每个奇怪的嵌套的孩子? [英] CSS refer to every odd nested child?

查看:129
本文介绍了CSS是指每个奇怪的嵌套的孩子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个评论系统,其中嵌套评论有斑马背景颜色。 (蓝色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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆