
批改狀態(tài):合格
老師批語(yǔ):
1、 flex-direction:row/colum:主軸方向,默認(rèn)主軸為行,
2、 flex-wrap:nowrap/wrap;默認(rèn)不換行
3、 flex-flow:簡(jiǎn)寫(xiě)direction和wrap;
4、 justify-content:flex-start/center/flex-end和space-between/space-evenly/space-around;
主軸上項(xiàng)目對(duì)其方式和排列方式
5、 align-items:flex-start/center/flex-end;項(xiàng)目在交叉軸上的對(duì)其方式
6、 align-content: space-between/space-evenly/space-around: 項(xiàng)目在交叉軸上多行時(shí)的排列方式
1、 order:為項(xiàng)目編號(hào)(int),值越小越靠前排列
2、 flex-grow/shrink/basis: grow/shrink的值為比例分配:0~1; basis:項(xiàng)目占據(jù)的主軸空間。簡(jiǎn)寫(xiě):flex:0,0 auto;
3、 aglin-self:某個(gè)特定項(xiàng)目的對(duì)齊方式;值為:flex-start、center、flex-end;
1、flex個(gè)屬性練習(xí):
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>flex布局小案例</title>
<style>
.box{
/* width: 40em; */
/* height: 15em; */
background-color: lightgray;
display: flex;
/* 存在剩空間可以通過(guò)space-between|space-evenly|space-around 來(lái)分配剩余空間*/
/* justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly; */
flex-flow:row nowrap;
align-items:flex-end;
/* 存在多行時(shí),副軸存在剩余空間時(shí),通過(guò)space-between|space-evenly|space-around 來(lái)分配剩余空間 */
align-content: space-around;
}
.box .item{
width:200px;
height:30px;
flex-grow: 1;
flex-shrink:0;
/* 設(shè)置元素自動(dòng)伸縮簡(jiǎn)寫(xiě):grow shrink basis */
flex:1;/*等同于1,1,auto*/
flex:none;/*等同于0 0 auto*/
flex:initial;/*等同于 0 1 auto*/
}
.box .item:nth-of-type(2n+1){
background-color: lightseagreen;
}
.box .item:nth-of-type(2n){
background-color: lightskyblue;
}
.box .item:nth-child(1){
order:4;
}
.box .item:nth-child(3){
order:5;
/* 設(shè)置第三個(gè)為基本寬度為 300px */
flex-basis:300px;
}
</style>
</head>
<body>
<div class="box">
<div class="item">01</div>
<div class="item">02</div>
<div class="item">03</div>
<div class="item">04</div>
</div>
</body>
</html>
2、效果圖:
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)