语法
flex-grow: value;
作用
当子元素的宽度/高度之和比父元素的宽度/高度小时,设置当前子元素占据剩余宽度/高度的比例值
选项值
纯数字。默认为0,即不占据剩余空间
示例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>堆代码-duidaima.com</title>
<style>
body {
padding: 0;
margin: 0;
}
.container {
font-size: 5em;
display: flex;
}
.top,
.bottom,
.left {
width: 100px;
height: 100px;
}
.top {
background-color: bisque;
flex-grow: 2;
}
.bottom {
background-color: rgb(77, 7, 243);
flex-grow: 1;
}
.left {
background-color: rgb(11, 240, 23);
flex-grow: 2;
}
</style>
</head>
<body>
<div class="container">
<div class="top">1</div>
<div class="bottom">2</div>
<div class="left">3</div>
</div>
</body>
</html>