- 左侧固定宽度,绝对定位
<!DOCTYPE html>
<html lang="en">
<style>
html,body{
width: 100%;
height: 100%;
overflow: hidden;
}
.container{
width: 100%;
height: 100%;
position: relative;
}
.left{
width: 200px;
height: 100%;
background-color: lightcyan;
position: absolute;
}
.right{
padding-left: 200px;
height: 100%;
background-color: lightgreen;
}
</style>
</head>
<body>
<div class="container">
<div class="left">left</div>
<div class="right">right</div>
</div>
</body>
</html>
- flex
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
html,body{
width: 100%;
height: 100%;
overflow: hidden;
}
.container{
width: 100%;
height: 100%;
display: flex;
}
.left{
width: 200px;
height: 100%;
background-color: lightcyan;
}
.right{
flex:1;
background-color: lightgreen;
}
</style>
</head>
<body>
<div class="container">
<div class="left">left</div>
<div class="right">right</div>
</div>
</body>
</html>
- table布局
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
html,body{
width: 100%;
height: 100%;
overflow: hidden;
}
.container{
width: 100%;
height: 100%;
display: table;
}
.left{
width: 200px;
height: 100%;
display: table-cell;
background-color: lightcyan;
}
.right{
display:table-cell;
background-color: lightgreen;
}
</style>
</head>
<body>
<div class="container">
<div class="left">left</div>
<div class="right">right</div>
</div>
</body>
</html>
- grid布局
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
html,body{
width: 100%;
height: 100%;
overflow: hidden;
}
.container{
width: 100%;
height: 100%;
display: grid;
/* 列的宽度,左侧固定,右侧auto */
grid-template-columns: 200px auto;
}
.left{
background-color: lightcyan;
}
.right{
background-color: lightgreen;
}
</style>
</head>
<body>
<div class="container">
<div class="left">left</div>
<div class="right">right</div>
</div>
</body>
</html>