<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flex demo 2</title>
<style>
.container {
display: flex;
flex-direction: column;/*改变主轴方向,column列从上往下,默认是row行从左往右*/
width: 400px;
height: 300px;
border: 1px solid #ccc;
}
.item {
flex: 1;
}
/* 总的是4份,每一项占一份 */
</style>
</head>
<body>
<div class="container">
<div class="item" style="background-color: #0ff; width: 200px"></div>
<div class="item" style="background-color: #ff0"></div>
<div class="item" style="background-color: #f00"></div>
<div class="item" style="background-color: #f0f"></div>
<div class="item" style="background-color: #0ff"></div>
</div>
</body>
</html>