Home > Article > Web Front-end > CSS telescopic box layout (summary sharing)
This article brings you relevant knowledge about css, which mainly introduces issues related to CSS telescopic box layout. An element sets the CSS attribute display:flex or display:inline-flex. , the element becomes a scalable container. Let’s take a look at it. I hope it will be helpful to everyone.
(Learning video sharing: css video tutorial, html video tutorial)
Flexible container: An element sets CSS propertiesdisplay:flex
or display:inline-flex
, the element becomes a flex container.
Scaling project: The child elements of the scaling container are the scaling projects.
Features of scalable projects:
- The scalable projects will be arranged horizontally in the scalable container by default.
- The scalable project can set the width, height, inner and outer margins, and there will be no margin collapse. It will not break away from the document flow and is scalable.
- An element can be a flex item and a flex container at the same time.
Spindle: Flexible items are arranged along the spindle, the default spindle direction It's from left to right.
Side axis: The axis perpendicular to the main axis is called the side axis, and the direction of the side axis changes with the direction of the main axis.
Give the CSS property to the flex container flex-direction You can set the main axis direction, the value is as follows:
row 水平从左到右,默认值 row-reverse 水平从右到左 column 垂直从上到下 column-reverse 垂直从下到上
Give the CSS property of the flex container flex-wrap You can set the line wrap method of the flex item in the main axis direction. The value of the property is as follows:
nowrap 默认值,不换行 wrap 自动换行 wrap-reverse 自动换行,行翻转
flex-flow is a composite property of flex-directrion and flex-wrap. You can set the main axis direction and line wrapping method at the same time. Line break mode.
flex-flow You can set 1 value or 2 values (there is no order requirement between the two values).
Set the justify-content attribute to the flex container to set the flex items on the main axis The alignment of No line breaks on top)
flex-start 默认值,主轴起始对齐 flex-end 主轴结束对齐 center 居中 space-between 两端没有空隙,中间有空隙 space-around 两端空隙是中间空隙的一半 space-enenly 两端空隙与中间空隙相等Multiple main axis lines (scaling The item wraps on the main axis)
Easily set the align-content
attribute for scaling. The attribute value is as follows:stretch 默认值,伸缩项目在侧轴方向的长度(高度)在侧轴方向拉伸(不设置在侧轴方向的长度,才会生效) flex-start 侧轴起点对齐 flex-end 侧轴终点对齐 center 居中对齐 baseline 文本基线对齐
align-content actually sets how to align multiple main axes.
The align-items property will work regardless of one main axis line or multiple main axis lines; but align-content only works for multiple main axis lines.
The base length of the flex project on the main axis flex-basis
- 5 The scalability of the flex project
Shrink ratio flex-shrink
The specified number represents the shrinkage ratio. The default value of this property is 1. The prerequisite for the shrinkage of the scalable project: The length of the scalable container is insufficient in the main axis direction.flex composite attribute
Set the expansion ratio, contraction ratio, and main axis reference length at the same time. The setting rules are as follows:strecch 默认值 flex-start 侧轴起点对齐 flex-end 侧轴终点对齐 center 居中对齐 space-between 两端没有空隙,中间有空隙 space-around 两端空隙是中间空隙的一半 space-enenly 两端空隙与中间空隙相等
flex: grow shrink basis;flex: 0 1 auto; /* 扩展比率是0,收缩比率是1,基准值是auto */
flex: 1; /* flex: 1 1 0; */flex: auto; /* flex: 1 1 auto; */flex: none; /* flex: 0 0 auto 不伸不缩*/flex: 0 auto; /* flex: 0 1 auto */
align-self
You can set the flex item individually The alignment of items on the cross axis. The value of the attribute is consistent with align-items.CSS Attribute name | Meaning | Value |
---|---|---|
Set the scaling container | flex: Block-level scalable container. **inline-flex:** Inline flex container. |
|
Set the main axis direction | row: Default value, horizontally from left to right. row-reverse: Horizontally from right to left. column: Vertically from top to bottom. **column-reverse:**Vertical from bottom to top |
|
Set the line wrapping method | nowrap : Default value, no line breaks. wrap: Automatically wrap lines. wrap-reverse: Automatically wrap and flip lines. |
|
Set the main axis direction and line wrapping method at the same time | The values of flex-dierection and flex-wrap | |
Set the alignment of flex items on the main axis | flex-start: Alignment of the main axis starting point. flex-end: Alignment of main axis end point. center: Center alignment. space-between: There is no space at both ends and there is space in the middle. **space-around:**The spaces at both ends are half of the space in the middle. **space-evenly:** The spaces at both ends are consistent with the space in the middle. |
|
Set the alignment of stretch items on the cross axis (applies to a main axis line) | stretch: Default value, stretch on the cross axis. flex-start: Align the starting point of the cross axis. flex-end: Alignment of cross axis end point. center: Center alignment. baseline: Baseline alignment. |
|
Set the alignment of flex items on the side axis (applicable to multiple main axis lines) | stretch: Default value, stretch on the cross axis. flex-start: Align the starting point of the cross axis. flex-end: Alignment of cross axis end point. center: Center alignment. space-between: There is no space at both ends and there is space in the middle. **space-around:**The spaces at both ends are half of the space in the middle. **space-evenly:** The spaces at both ends are consistent with the space in the middle. |
Meaning | Value | |
---|---|---|
Expansion ratio | Number, the default value is 0 | |
Shrink ratio | Number, the default value is 1 | |
The reference length on the main axis | Specify the length, the default value is auto | |
Composite attribute, and set grow shrink basis | grow shrink basis | |
The order of shrinking items | Number, the default value is 0 | |
Separately set the alignment of flex items on the cross axis | **auto: **Default value, according to the settings of the flex container. |
stretch: Default value, stretches on the cross axis. flex-start: Align the starting point of the cross axis. flex-end: Alignment of cross axis end point. center: Center alignment. baseline: Baseline alignment. |
The above is the detailed content of CSS telescopic box layout (summary sharing). For more information, please follow other related articles on the PHP Chinese website!