关键代码是width: 0;如下:
<!DOCTYPE html>
<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.0" />
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.con {
background-color: red;
width: 100vw;
height: 100vh;
display: flex;
padding-bottom: 10px;
}
.left {
width: 200px;
height: 100%;
background-color: yellow;
flex-shrink: 0;
}
.right {
flex: 1;
background-color: aqua;
width: 0; /* 关键一行 */
}
.top {
height: 200px;
background-color: blue;
display: flex;
}
.item1 {
width: 200px;
height: 200px;
background-color: orange;
flex-shrink: 0;
}
.item2 {
background-color: chartreuse;
overflow-x: scroll;
flex-direction: row;
justify-content: space-around;
overflow-x: scroll;
flex: 1 1 100%;
height: 200px;
}
.item3 {
width: 1200px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div class="con">
<div class="left"></div>
<div class="right">
<div class="top">
<div class="item1">1</div>
<div class="item2">
<div class="item3"></div>
</div>
<div class="item1"></div>
</div>
</div>
</div>
</body>
<script></script>
</html>