How do I group div items by year in a CSS grid without specifying the year in the CSS? The year is included as a data-group attribute in every div. I want to pick the last divs of any year for .year, .link and .title and group them with a border.
I need to do something like below but it doesn't work at all. I need to group items by year without actually knowing what year it is.
.year[data-group="unknown"]:last-of-type {
border-bottom: 1px solid gray;
}
<div class="grid">
<div data-group="2018" class="year">2018</div>
<div data-group="2018" class="link"><a href="#"></a></div>
<div data-group="2018" class="title">Avengers: Infinity War <span>as Natasha Romanoff / Black Widow</span></div>
<div data-group="2017" class="year">2017</div>
<div data-group="2017" class="link"><a href="#"></a></div>
<div data-group="2017" class="title">Ghost In The Shell <span>as Major Mira Killian / Motoko Kusanagi</span></div>
<div data-group="2017" class="year">2017</div>
<div data-group="2017" class="link"><a href="#"></a></div>
<div data-group="2017" class="title">Thor: Ragnarok <span>as Natasha Romanoff / Black Widow (archive footage / uncredited)</span></div>
</div>