css flex

css

flex

盒子

  • 定义

display: flex;
display: inline-flex;

  • 方向 水平,反向水平,垂直,反向垂直

flex-direction: row | row-reverse | column | column-reverse;

  • 换行 不换行,换行,换行到上/前面

flex-wrap: nowrap | wrap | wrap-reverse;

  • 对齐 左,右,中,两端,自适应间距

justify-content: flex-start | flex-end | center | space-between | space-around

  • 垂直对齐 上,下,中,基线,拉伸

align-items: flex-start | flex-end | center | baseline | stretch;

  • 多行对齐,基于盒子,和justify-content相似

align-content: flex-start | flex-end | center | space-between | space-around | stretch;

项目

  • 排序, 数字越小越靠前

order: integer;

  • 放大比例, 默认都是0,如果都是1,宽度相等

flex-grow: number; /* default 0 */

  • 缩小比例,默认是1,如果空间不够,就会缩小,如果是0,不缩小

flex-shrink: number; /* default 1 */

  • 项目所占固定空间

flex-basis: length | auto; /* default auto */

  • 复合 0 1 auto

flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]

  • 覆盖上级对齐方式 align-item

align-self: auto | flex-start | flex-end | center | baseline | stretch;

上下左右居中

display:flex
justify-content:space-around;
align-items:center

posted @ 2022-07-09 10:55  jqynr  阅读(37)  评论(0)    收藏  举报