由于flex-grow不能很好解决最后一个div框与其他框长度问题,自己实现了一个自动计算宽度来动态调整大小的布局
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>左右结构div自动伸缩</title>
<script src="./asserts/js/jquery-3.6.3.min.js"></script>
<style></style>
<script type="text/javascript"></script>
</head>
<body>
<div style="height: 200px; width: 100%; position: relative; border: 1px solid rgb(107, 98, 98)">
<div style="height: 200px; width: 300px; position: absolute; background-color: aqua"></div>
<div style="height: 200px; width: calc(100vw - 320px); float: right; background-color: blue; display: flex; flex-direction: row; flex-wrap: wrap">
<div style="height: 200px; width: 200px; background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; width: 200px; background-color: rgb(11, 182, 182)"></div>
</div>
</div>
<div style="height: 500px; width: 100%; position: relative; border: 1px solid red">
<div style="height: 500px; width: 300px; position: absolute; background-color: aqua"></div>
<div style="height: 500px; width: calc(100vw - 320px); float: right; background-color: blue">
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
<div style="height: 200px; float: left; margin: 15px; width: calc((100% - 120px - 15px * 5) / 5); background-color: rgb(11, 182, 182)"></div>
</div>
</div>
</body>
</html>