Oh horror, the worst option I have.
As an option to wrap everything in one div and throw divas there with backgrounds with a "margin" for the widest monitor.
There are downsides: ie up to 10 is not supported, the last block will be added if the width of the container is a multiple of the width of the blocks.
This is a crutch g / code, so I would recommend using jQuery not only css, but all the same. Then it will be possible to calculate the width of the container and gash how many investments are needed and the last block of the required width.
As an option to generate an image on the server and insert it into the background with a repetition horizontally. For generation it will be necessary to write at least some model.
.flex { display: flex; flex-wrap: wrap; width: 500px; max-height: 100px; overflow: hidden; } .flex > div { width: 100px; height: 100px; } .flex > div.clr1 { background: #FF0000; } .flex > div.clr2 { background: #FF9000; } .flex > div.clr3 { background: #FCFF00; } .flex > div.clr4 { background: #12FF00; }
<div class="flex"> <div class="clr1"></div> <div class="clr2"></div> <div class="clr3"></div> <div class="clr4"></div> <div class="clr1"></div> <div class="clr2"></div> <div class="clr3"></div> <div class="clr4"></div> <div class="clr1"></div> <div class="clr2"></div> <div class="clr3"></div> <div class="clr4"></div> <div class="clr1"></div> <div class="clr2"></div> <div class="clr3"></div> <div class="clr4"></div> <div class="clr1"></div> <div class="clr2"></div> <div class="clr3"></div> <div class="clr4"></div> </div>