第一种方案display:table
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
body,p{
margin: 0;
padding: 0;
}
.parent{
display: table;
width: 100%;
}
.left{
display: table-cell;
width: 100px;
background: yellowgreen;
border-right: 20px solid transparent;
background-clip: padding-box;
}
.right{
background: pink;
display: table-cell;
}
</style>
</head>
<body>
<div class="parent">
<div class="left">
<p>left</p>
</div>
<div class="right">
<p>right</p>
<p>right</p>
<p>right</p>
<p>right</p>
</div>
</div>
</body>
</html>
第二种解决方案 flex
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
body,p{
margin: 0;
padding: 0;
}
.parent{
display: flex;
}
.left{
background: yellowgreen;
width: 100px;
}
.right{
background: pink;
flex: 1;
margin-left: 20px;
}
</style>
</head>
<body>
<div class="parent">
<div class="left">
<p>left</p>
</div>
<div class="right">
<p>right</p>
<p>right</p>
<p>right</p>
</div>
</div>
</body>
</html>
第三种方式float(兼容性好)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
body,p{
margin: 0;
padding: 0;
}
.parent{
overflow: hidden;
}
.left,.right{
padding-bottom: 9999px;
margin-bottom: -9999px;
}
.left{
background: yellowgreen;
float: left;
margin-right: 20px;
}
.right{
overflow: hidden;
background: pink;
}
</style>
</head>
<body>
<div class="parent">
<div class="left">
<p>left</p>
</div>
<div class="right">
<p>right</p>
<p>right</p>
<p>right</p>
<p>right</p>
<p>right</p>
</div>
</div>
</body>
</html>