Does alternate row color works only for table or for any other tag Ex. Div [closed]

匆匆过客 提交于 2021-02-10 18:41:01

问题


I have created rows without using a table since it was not cooperating with my Handlebars template and now want to have zebra stripe CSS, I want to know if that css property can work on everything or not. Thanks


回答1:


Not necessary you can still use div to do the same job, something like below:

.box:nth-child(odd) {
    background: blue;
}
.box:nth-child(even) {
    background: yellow;
}
<div class="box">First row</div>
<div class="box">second row</div>
<div class="box">third row</div>
<div class="box">fourth row</div>


来源:https://stackoverflow.com/questions/60789227/does-alternate-row-color-works-only-for-table-or-for-any-other-tag-ex-div

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!