How to implement a layout that automatically adapts to the width?

how to implement a layout that adapts to the width automatically with pure css?

for example: in div, the minimum width of a sub-div is 200 and the maximum width is 250. when the browser window becomes wider, the number of each row automatically increases, and all the sub-div of each line are full of width, and the edges cannot be left blank.

can it be achieved with flex or grid? (it is best not to use media query)

Mar.20,2021

simply and rudely give you a reference

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>autowidth</title>
  <style type="text/css">
    .container {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
    }
    .item {
      min-width: 200px;
      max-width: 250px;
      height: 100px;
      background: -sharpeee;
      margin: 5px;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
  </div>
</body>
</html>

refer to @ Yang Bai answer

style changed to
clipboard.png


clipboard.png


try setting a percentage for the width of the sub-div

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3928e-2c163.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3928e-2c163.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?