所以我想弄清楚如何重复两个交替的div。基本上,我正在制作一个wordpress网站,我希望帖子以他们看起来的方式交替。我也在使用bootstrap。
所以使用这段代码完成的第一篇文章:
<div class="row">
<div class="col-sm-4">
<img src="xyz.png">
</div>
<div class="col-sm-8">
<p>random text random text</p>
</div>
</div>
然后第二篇文章将有相同的东西,但文本和图像切换方。
如果可能,我该怎么做?
答案 0 :(得分:3)
如果您只是希望它们具有不同的样式,则不需要为每个其他行提供不同的类。只需使用:nth-of-type(odd)
或:nth-of-type(even)
选择器选择要设置样式的每一行。
.row{
/* styling */
}
.row:nth-of-type(odd){
/* alternative styling for your every other row */
}