<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.root {
background: #2B3A42;
height: 600px;
width: 400px;
display: flex; /*弹性盒子模型*/
flex-direction: row;
align-items: center; /*上下居中*/
justify-content: center; /*左右对齐*/
}
/*
权重的计算,每个元素的权重占全部值的除
*/
.box1 {
width: 100px;
height: 150px;
background: #f1f1f1;
margin: 5px;
/*flex: 1; !*权重确定宽度,如果使用权重flex,则宽度不会生效*!*/
order: 3;
}
.box2 {
width: 100px;
height: 150px;
background: #f1f1f1;
margin: 5px;
/*flex: 1;*/
order: 2; /*改变元素的顺序*/
}
.box3 {
width: 100px;
height: 150px;
background: #f1f1f1;
margin: 5px;
/*flex: 1;*/
order: 1;
}
</style>
</head>
<body>
<div class="root">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
</body>
</html>
以element-ui Tree为例子来展示Flex布局:
in line 4, append css "custome-tree-node" as below: