JSFiddle - React, Tailwind, and code Playground
by Qwerty_Wasd
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.img-wrap {
display: grid;
}
#rb2:checked~.img-wrap {
grid-template-columns: repeat(2, -webkit-max-content);
grid-template-columns: repeat(2, max-content);
}
#rb3:checked~.img-wrap {
grid-template-columns: repeat(3, -webkit-max-content);
grid-template-columns: repeat(3, max-content);
}
#rb4:checked~.img-wrap {
grid-template-columns: repeat(4, -webkit-max-content);
grid-template-columns: repeat(4, max-content);
}
#rb6:checked~.img-wrap {
grid-template-columns: repeat(6, -webkit-max-content);
grid-template-columns: repeat(6, max-content);
}
</style>
</head>
<body>
<input id="rb2" type="radio" name="RB" value="2" checked>2
<input id="rb3" type="radio" name="RB" value="3">3
<input id="rb4" type="radio" name="RB" value="4">4
<input id="rb6" type="radio" name="RB" value="6">6
<div class="img-wrap">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230" height="341">
<img src="https://dummyimage.com/100x100/969696/fff.png" alt="" width="230"...