jsp 怎么实现 回复和评论的等级缩进排布,用树结构吗?还是用<li>,<ul>?还是自定义css

我可以实现对回复的等级做判断,关键不知道怎么实现css的布局
子回复是挂在父回复的下面:如图,1楼是回复文章的,2楼是回复1楼的,3楼是回复2楼的....5楼是回复1楼的..
所以需要有不同程度的向后“缩减”
问题就是怎么去控制这个样式?
我刚尝试通过<%=参数%>来控制,可以做到类似引用函数的方式控制css,不知这样是不是合理????

https://img4.mukewang.com/5c29c94300017f5a07190482.jpg

拉风的咖菲猫
浏览 653回答 1
1回答

米琪卡哇伊

由于这个样式不涉及到每一层独立的样式,都是向后缩进一点,所以层级没有必要用到,结构类似下面这样:html<ul>&nbsp; &nbsp; <li class="list-item">&nbsp; &nbsp; &nbsp; &nbsp; <div class="main"> ... </div>&nbsp; &nbsp; &nbsp; &nbsp; <!-- 没有子评论就不显示ul.child -->&nbsp; &nbsp; </li>&nbsp; &nbsp; .....&nbsp; &nbsp; <li class="list-item">&nbsp; &nbsp; &nbsp; &nbsp; <div class="main"> ... </div>&nbsp; &nbsp; &nbsp; &nbsp; <ul class="child"><!-- 这层是一级子评论 -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li class="list-item">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="main"> ... </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class="child"><!-- 这层是二级子评论 -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li class="list-item"></li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...&nbsp; &nbsp; &nbsp; &nbsp; </ul></ul>CSS:.list-item > .main {&nbsp; &nbsp; ...}.list-item > ul.child {&nbsp; &nbsp; margin-left: ....;&nbsp; &nbsp; ....}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript