Applying nth-child() when flex items are in column-reverse
<p>Let's say I'm using a plugin that's adding content chronologically to my page. The plugin does not give me control of the amount of items added to the page or the order that they are added to the page.</p>

<p>So let's say that this is what my HTML looks like after 5 items have been added to the page:</p>

<pre><code>&lt;div class="flex-container"&gt;
  &lt;div class="flex-item"&gt;First&lt;/div&gt;   &lt;!-- Posted 4 days ago --&gt;
  &lt;div class="flex-item"&gt;Second&lt;/div&gt;  &lt;!-- Posted 3 days ago --&gt;
  &lt;div class="flex-item"&gt;Third&lt;/div&gt;   &lt;!-- Posted 2 days ago --&gt;
  &lt;div class="flex-item"&gt;Fourth&lt;/div&gt;  &lt;!-- Posted 1 day ago --&gt;
  &lt;div class="flex-item"&gt;Fifth&lt;/div&gt;   &lt;!-- Posted today --&gt;
&lt;/div&gt;
</code></pre>

<p>I want to reverse the order so that the most recent item is displayed first so I use:</p>

<pre><code>.flex-container {
  display:flex;
  flex-direction:column-reverse;
}
</code></pre>

<p>Now, my items are being displayed in this order:</p>

<pre><code>Fifth
Fourth
Third
Second
First
</code></pre>

<p>Now let's say that I only want a maximum of 3 items to appear on the page. How can I do that with the new sequence that the items are displayed in? </p>

<p>If the items weren't being reversed with css, I could remove anything after 3 items with this:</p>

<pre><code>.flex-item:nth-child(n+4) {
  display:none;
}
</code></pre>

<p>But since they're reversed, the above css is removing the last two most recent posts. </p>

<h2>TL;DR</h2>

<p>Is css able to remove children based on the sequence that css has reordered them in or will I need to use js to reorganize the html?</p>