最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

移動(dòng)端系列(flex布局)

標(biāo)簽:
Html/CSS
弹性盒子  display: flex,采用Flex布局的元素,称为Flex容器(flex container),简称”容器”。它的所有子元素自动成为容器成员,称为Flex项目(flex item),简称”项目”。

PS:flex布局首先要理清楚主轴和侧轴,因为flex的属性很多是根据主侧轴进行布局

  • 父容器属性:

flex-direction 设置主轴方向
  • row  从左向右排列(默认值)

  • row-reverse 从右向左排列

  • column 从上往下排列

  • column-reverse 从下往上排列

//flex.scss
 .fix_box {  list-style: none;
  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: column; //设置主轴方向
  .item {
    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
}

webp

image.png

justify-content 主轴对齐
  • flex-start (默认) 元素在开始位置 富裕空间占据另一侧

  • flex-end 富裕空间在开始位置 元素占据另一侧

  • center 元素居中 富裕空间 平分左右两侧

  • space-between 富裕空间在元素之间平均分配

  • space-around  富裕空间在元素两侧平均分配

//flex.scss.fix_box {
  margin: 0;
  padding: 0;  list-style: none;
  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  justify-content: space-between;  //富裕空间在元素之间平均分配
  .item {
    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
}

webp

image.png

align-items 侧轴对齐
  • flex-start (默认) 元素在开始位置 富裕空间占据另一侧

  • flex-end 以侧轴结束一侧

  • center 元素居中 富裕空间 平分左右两侧

.fix_box {
  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  align-items: flex-end;  //flex-end 以侧轴结束一侧
  // justify-content: space-between;
  .item {
    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
}

webp

image.png

flex-wrap 换行
  • flex-wrap 换行

  • nowrap (默认)

  • wrap 换行

  • wrap-reverse 反向换行

.fix_box {
  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  .item {
    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
}

webp

image.png

align-content 堆栈伸缩行
  • align-content 会更改 flex-wrap(容器换行) 的行为。它和 align-items 相似,但是,不是对齐伸缩项目,它对齐的是伸缩行。

  • flex-start (默认) 元素在开始位置 富裕空间占据另一侧

  • flex-end 富裕空间在开始位置 元素占据另一侧

  • center 元素居中 富裕空间 平分左右两侧

  • space-between 富裕空间在元素之间平均分配

  • space-around  富裕空间在元素两侧平均分配

.fix_box {
  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: space-around; //富裕空间在元素两侧平均分配
  .item {
    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
}

webp

image.png

  • 子容器属性:

order 容器排序
  • 数字越大,顺序越往后,越小越靠前,支持负数

.fix_box {  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  .item {    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
  .item:nth-of-type(1){    order: 1
  }
  .item:nth-of-type(2){    order: 12
  }
  .item:nth-of-type(3){    order: 3
  }
  .item:nth-of-type(4){    order: 4
  }
  .item:nth-of-type(5){    order: 5
  }
  .item:nth-of-type(6){    order: 6
  }
  .item:nth-of-type(7){    order: 7
  }
  .item:nth-of-type(8){    order: 8
  }
  .item:nth-of-type(9){    order: 9
  }
  .item:nth-of-type(10){    order: -1
  }
}

webp

image.png

flex 伸缩性
  • flex: auto

  • flex: none

  • flex: number

我这里将每个子容器一共分成55份,flex后面的数字表示55分之几

.fix_box {  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  .item {    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
  .item:nth-of-type(1){    flex:1
  }
  .item:nth-of-type(2){    flex:2
  }
  .item:nth-of-type(3){    flex:3
  }
  .item:nth-of-type(4){    flex:4
  }
  .item:nth-of-type(5){    flex:5
  }
  .item:nth-of-type(6){    flex:6
  }
  .item:nth-of-type(7){    flex:7
  }
  .item:nth-of-type(8){    flex:8
  }
  .item:nth-of-type(9){    flex:9
  }
  .item:nth-of-type(10){    flex:10
  }
}

webp

image.png

align-self 子元素侧轴对齐
  • flex-start (默认) 元素在开始位置 富裕空间占据另一侧

  • flex-end 富裕空间在开始位置 元素占据另一侧

  • center 元素居中 富裕空间 平分左右两侧

.fix_box {  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  flex-direction: row;
  .item {    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
  }
  .item:nth-of-type(1){    flex:1;
  }
  .item:nth-of-type(2){    flex:2
  }
  .item:nth-of-type(3){    flex:3
  }
  .item:nth-of-type(4){    flex:4
  }
  .item:nth-of-type(5){    flex:5;
    align-self:center;  //元素居中 富裕空间 平分左右两侧
  }
  .item:nth-of-type(6){    flex:6
  }
  .item:nth-of-type(7){    flex:7;
    align-self:center;  //元素居中 富裕空间 平分左右两侧
  }
  .item:nth-of-type(8){    flex:8
  }
  .item:nth-of-type(9){    flex:9
  }
  .item:nth-of-type(10){    flex:10
  }
}

webp

image.png

margin:auto 居中显示
  • margin:auto配合display:flex使用可以直接是子容器居中于父容器当中,可以减少大量css样式操作

.fix_box {
  width: 800px;
  height: 500px;
  border: 5px solid pink;
  display: flex;
  .item {
    width: 80px;
    height: 80px;
    background-color: yellow;
    border: 1px solid black;
    text-align: center;
    line-height: 80px;
    margin: auto; //居中显示
  }
}

webp

image.png



作者:饥人谷_米弥轮
链接:https://www.jianshu.com/p/a1ba5a050679


點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消