Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:总结的不错哟, 作业的排列非常棒
row
和column
wrap
和nowrap
flex-start
、flex-end
和center
,默认为flex-start
;另外还可以可以分配主轴上的剩余空间,有三个选项:space-between
、space-around
和space-evenly
flex-start
、flex-end
和center
,默认为flex-start
justify-content
相同float
,就像老师说的:float是魔鬼,能不用就不用
,容易造成布局错乱,兼容性差+
选择相邻元素:input[type='search'] + label
表示input相邻的label
元素img
图片下部分有空白,可以用display:block
或者font-size:0
去除float:left
时,一行能显示4个,两行正好显示8个,而使用display:inline-block
时,一行只能显示3个,8个分成了3行,display:inline-block
有什么特殊之处?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>flex练习</title>
<style>
.container{
display: flex;
width: 620px;
/*border:2px dashed lightblue;*/
background-color: gray;
box-sizing: border-box;
}
.item{
width: 100px;
height: 50px;
border:1px dashed red;
background-color: lightgreen;
box-sizing: border-box;
text-align: center;
line-height: 50px;
}
.container.demo2{ /**允许换行**/
height: 200px;
flex-wrap: wrap;
}
.container.demo3{ /**纵轴换行**/
height: 200px;
flex-flow:column wrap;
}
.container.demo4{ /**居中对齐方式**/
height: 200px;
flex-flow:row wrap;
justify-content: center;
}
.container.demo5{ /**右对齐方式**/
height: 200px;
flex-flow:row wrap;
justify-content: flex-end;
}
.container.demo6{ /**间距**/
height: 200px;
flex-flow:row wrap;
justify-content: space-around;
}
.container.demo7{ /**间距**/
height: 200px;
flex-flow:row wrap;
justify-content: space-between;
}
.container.demo8{ /**纵轴间距**/
height: 200px;
flex-flow:column wrap;
justify-content: space-evenly;
}
.container.demo9{ /**副轴多行**/
height: 200px;
flex-flow:row wrap;
justify-content: space-between;
align-content: space-evenly;
}
.container.demo10{ /**副轴单行**/
height: 200px;
flex-flow:row wrap;
justify-content: space-between;
align-items: center;
}
</style>
</head>
<body>
<h1>demo1:行轴不换行</h1>
<div class="container demo1">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo2:行轴换行</h1>
<div class="container demo2">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo3:flex-flow方式</h1>
<div class="container demo3">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo4:对齐方式</h1>
<div class="container demo4">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo5:右对齐方式</h1>
<div class="container demo5">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo6:间距</h1>
<div class="container demo6">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo7:间距</h1>
<div class="container demo7">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo8:纵轴间距</h1>
<div class="container demo8">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo9:行轴主轴,副轴多行排列方式</h1>
<div class="container demo9">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
<span class="item">6</span>
<span class="item">7</span>
<span class="item">8</span>
</div>
<hr>
<h1>demo10:行轴主轴,副轴单行排列方式</h1>
<div class="container demo9">
<span class="item">1</span>
<span class="item">2</span>
<span class="item">3</span>
<span class="item">4</span>
<span class="item">5</span>
</div>
</body>
</html>