如何在每组两个列表元素之后插入换行符?它不一定需要是 HTML <br />
,而只是将接下来的两个元素移动到下一行的东西。尝试在这里完全使用 CSS/3(通过 jQuery)。
HTML:
<div id="headline_gallery">
<ul>
<li><img src="images/picture1.png" alt="picture1" /></li>
<li><img src="images/picture2.png" alt="picture2" /></li>
<li><img src="images/picture3.png" alt="picture3" /></li>
<li><img src="images/picture4.png" alt="picture4" /></li>
</ul>
</div>
CSS:
#headline_gallery li:nth-child(4n),#headline_gallery li:nth-child(4n-1) {
background:red;
display:inline;
}
#headline_gallery li:nth-child(4n-2),#headline_gallery li:nth-child(4n-3) {
background:blue;
display:inline;
}