There is a way to do it, the only caveat is that you know the height of the child. Having a fixed value for the child you can build a background
in the father. The idea is not to use bg in the son where the order may vary, but rather in the father who will grow up in a controlled way since you know the height of the son.
Note that even deleting a child in the middle, even so the order of the stripes follows coherent. It "adapts" to the child independent of the order...

What we have here is a father with a repeat-liner-gradient
, where each color band te the height of the child, in case 30px + borda
. So no matter the order or how many children you have the striped gradient at the bottom always come to fit the children.
Follows the code
.pai{
width: 300px;
display: flex;
flex-wrap: wrap;
background-image: repeating-linear-gradient(to bottom, #ccc 0px, #ccc 31px, #fff 31px, #fff 62px);
background-size: 80% 100%;
background-repeat-x: no-repeat;
}
.filho{
width: 80%;
margin-top: -1px;
border: 1px solid black;
line-height: 30px;
box-sizing: border-box;
}
.ordem1{order:1}
.ordem2{order:2}
.ordem3{order:3}
.ordem4{order:4}
.ordem5{order:5}
<div class="pai">
<div class="filho ordem5">Zebra5 (cinza)</div>
<div class="filho ordem3">Zebra3 (cinza)</div>
<div class="filho ordem4">Zebra4 (branca)</div>
<div class="filho ordem2">Zebra2 (branca)</div>
<div class="filho ordem1">Zebra1 (cinza)</div>
</div>
Do you want them to be alternating between gray and white? In case, wouldn’t it be better to put the color within the order class? Or already receive ordered?
– Felipe Avelar
Yes, zebras between gray and white obeying the css order property.
– Pedro Augusto
I already get paid
– Pedro Augusto
With Javascript you can sort the Divs by class
ordem
without having to use theorder
flex. See an example: https://jsfiddle.net/g95f712u/– Sam