<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>align-items</title>
<style type="text/css">
.flex-container {
/*
align-items: 定义flex子项在flex容器的当前行的交叉轴方向上的对齐方式(仅限单行子元素);
-- stretch 拉伸,默认值; 项目被拉伸以适应容器.注意不能给子项 交叉轴方向的长度
-- center 使项目位于容器的中心,挤在一起主轴(交叉轴)居中
-- flex-start: ;
-- flex-end: ;
*/
width: 800px;
height: 400px;
background-color: orange;
display: flex;
flex-direction: column;
/*flex-wrap: wrap;*/
justify-content: center;
/*align-items: center;*/
align-items: center;
}
.flex-item {
/*width: 100px;*/
height: 100px;
background-color: pink;
margin: 0 10px;
margin-bottom: 20px;
}
.flex-item:nth-child(2) {
width: 250px;
/*height: 250px;*/
background-color: blue;
}
</style>
</head>
<body>
<div class="flex-container">
<div class="flex-item">1</div>
<div class="flex-item">2</div>
<div class="flex-item">3</div>
<div class="flex-item">4</div>
<div class="flex-item">5</div>
<div class="flex-item">6</div>
<div class="flex-item">7</div>
<div class="flex-item">8</div>
<div class="flex-item">9</div>
</div>
</body>
</html>
上述运行结果: