我尝试过:nth-of-type但是我不确定是否可能,或者该功能是否真的需要我。我需要一种交替的风格:左边是两个段落,右边是两个,依此类推,即使我添加了新段落。
这概括了我的意思:
Paragraph
Paragraph
Paragraph
Paragraph
Paragraph
Paragraph
Paragraph
Paragraph
答案 0 :(得分:4)
以这种方式:
p {
clear:both;
float:left;
}
p:nth-of-type(4n+3), p:nth-of-type(4n+4) {
float:right;
}

<p>paragraph 1</p>
<p>paragraph 2</p>
<p>paragraph 3</p>
<p>paragraph 4</p>
<p>paragraph 5</p>
<p>paragraph 6</p>
<p>paragraph 7</p>
<p>paragraph 8</p>
&#13;
答案 1 :(得分:0)
答案 2 :(得分:0)
尝试玩nth-child(4n + x)
一种可能的解决方案......
p:nth-child(4n+1), P:nth-child(4n+2) {
// left styles
}
p:nth-child(4n+3), p:nth-child(4n+4) {
// right styles
}