好久没更新了
This commit is contained in:
112
csspress/demo/flexjiaochazhou.html
Normal file
112
csspress/demo/flexjiaochazhou.html
Normal file
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
*{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.box{
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: pink;
|
||||
display:flex;
|
||||
/* 通过display:flex来把目标元素设置成flex布局 */
|
||||
flex-direction: row;
|
||||
/* flex-direction 属性决定主轴的方向,值为row的时候水平排列 起点在左 */
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
.box1{
|
||||
width: 1000px;
|
||||
height: 500px;
|
||||
background: gold;
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
|
||||
}
|
||||
.left,.left1{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: red;
|
||||
}
|
||||
.right,.right1{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: blue;
|
||||
}
|
||||
.box3{
|
||||
align-items: flex-end;
|
||||
}
|
||||
.box4{
|
||||
align-items: baseline ;
|
||||
}
|
||||
.box5{
|
||||
align-items: stretch;
|
||||
}
|
||||
.lefta{
|
||||
height:auto
|
||||
}
|
||||
.boxfin{
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="margin-bottom: 50px;">
|
||||
注:以下所有实例 基于flex-direction:row的情况,即水平排列 起点在左边
|
||||
且 主轴为默认
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items:center 居中的状况
|
||||
</div>
|
||||
|
||||
<div class="box1">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items: flex-start; 起点在上面
|
||||
</div>
|
||||
|
||||
<div class="box box4">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items:base-line 项目的第一行文字的基线对齐的情况
|
||||
</div>
|
||||
|
||||
<div class="box1 box5">
|
||||
<div class="left lefta"></div>
|
||||
<div class="right lefta"></div>
|
||||
|
||||
</div>
|
||||
<div style=" margin-bottom: 30px;">
|
||||
上面是 align-items:stretch(默认值) 如果项目未设置高度或设为auto,将占满整个容器的高度。
|
||||
</div>
|
||||
|
||||
<div class="box1 boxfin">
|
||||
<div class="left"></div>
|
||||
<div class="right"></div>
|
||||
|
||||
</div>
|
||||
<div class="zong">
|
||||
总结1:flex-direction属性定义的是主轴方向,默认为水平,所以 交叉轴方向默认为垂直;
|
||||
<p>当 flex-direction的值为column的时候,align-items决定的就是垂直方向的排列方式</p>
|
||||
<b>align-items决定的是交叉轴的排列方式 而不一定是单指 垂直的排列方式</b>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user