css布局 左侧固定 右边自适应屏幕
方式一
<!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>
body{
margin:0;
}
.main{
height:100vh;
background:skyblue;
display: flex;
}
.col1{
width:200px;
background:pink;
}
.col2{
flex: 1;
background:springgreen;
}
</style>
</head>
<body>
<div class="main">
<div class="col1"></div>
<div class="col2"></div>
</div>
</body>
</html>
方式二
<!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>
body{
margin:0;
}
.main{
height:100vh;
background:skyblue;
}
.col1{
width:200px;
height:60%;
float:left;
background:pink;
}
.col2{
height:100%;
background:lightcoral;
margin-left:200px;
overflow: hidden;
}
</style>
</head>
<body>
<div class="main">
<div class="col1"></div>
<div class="col2"></div>
</div>
</body>
</html>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4daf55b11b17753772e7b919b4571dfb.png)