css3的flex應用總結

2021-08-17 11:52:59 字數 2185 閱讀 4406

每次寫都要找,還是自己總結一下來,可以隨時看,非常方便!

常用:怪異和模型

box-sizing:border-box;

-moz-box-sizing:border-box; /* firefox */

-webkit-box-sizing:border-box; /* safari */

1,flex盒子

display: -webkit-flex; /* safari */

display: flex;

display: box;              /* old - android 4.4- */

display: -webkit-box; /* old - ios 6-, safari 3.1-6 */

display: -moz-box; /* old - firefox 19- (buggy but mostly works) */

display: -ms-flexbox; /* tweener - ie 10 */

display: -webkit-flex; /* new - chrome */

display: flex; /* new, spec - opera 12.1, firefox 20+ */

水平垂直居中

-webkit-justify-content: center;

-o-justify-content: center;

justify-content: center;

-webkit-align-items: center;

-o-align-items: center;

align-items: center;

2,水平居中

-webkit-justify-content: center;

-moz-justify-content: center;

-ms-justify-content: center;

-o-justify-content: center;

justify-content: center;

3,豎直居中

-webkit-box-align: center;

-webkit-align-items: center;

-moz-align-items: center;

-ms-align-items: center;

-o-align-items: center;

align-items: center;

4,水平兩端對齊

-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;

5,子元素-平均分欄 

-webkit-box-flex: 1;

-moz-box-flex: 1;

-webkit-flex: 1;

-ms-flex: 1;

flex: 1;

6,橫向換行

-webkit-box-lines: multiple;*/

/* 12版 */

-webkit-flex-wrap: wrap;

-moz-flex-wrap: wrap;

-ms-flex-wrap: wrap;

-o-flex-wrap: wrap;

flex-wrap: wrap;

7,縱向排列

/* 09版 */

-webkit-box-orient: vertical;

/* 12版 */

-webkit-flex-direction: column;

-moz-flex-direction: column;

-ms-flex-direction: column;

-o-flex-direction: column;

flex-direction: column;

CSS3彈性布局flex

彈性盒子由彈性容器 flex container 和彈性子元素 flex item 組成。彈性容器通過設定 display 屬性的值為 flex 或 inline flex將其定義為彈性容器。彈性容器內包含了乙個或多個彈性子元素。注意 彈性容器外及彈性子元素內是正常渲染的。彈性盒子只定義了彈性子元素...

CSS3 彈性布局 flex

彈性布局 彈性布局又稱彈性盒子,伸縮盒子,是css3中的有一種布局方法,主要用來代替浮動float來完成頁面布局 可以使元素具有彈性,可以根據瀏覽器視窗的大小,進行自適應的放大縮小。要使用彈性布局,就必須先將乙個元素設定為彈性容器 我們可以通過 display 來設定彈性容器 display fle...

CSS3 彈性布局flex

css3中的彈性布局也叫flex布局,它是我們現在主要用的布局方式之一 它的優點就是方便快捷,有更大的靈活性 彈性盒子包括 彈性容器和彈性子元素,彈性容器dispaly flex 彈性子元素flex item 容器屬性 1.換行 flex wrap wrap nowrap 預設 不換行,所有子元素都...